How can the presence of a dot (.) before the URL path cause unexpected behavior when using header() function in PHP?

When a dot (.) is present before the URL path in the header() function in PHP, it can cause unexpected behavior because PHP interprets it as a relative path instead of an absolute path. To solve this issue, you can use the full URL including the protocol (http:// or https://) in the header() function to ensure that the redirect works correctly.

// Incorrect way with dot (.) before URL path
header('Location: .example.com');

// Correct way with full URL including protocol
header('Location: http://example.com');