I'm currently writing a few pages and within some pages I have the following header to redirect in certain cases:
This code works perfect when i'm accessing it through http://localhost/current_page and it will redirect me back to http://localhost/index.php
However, if i'm accessing it through a ip address such as http://ip_address/current_page it will try to redirect me to http://ip_address\/index.php and of course that's a invalid url and it get the page cant be found issue.
I have not changed any code for this to happen, any ideas where or why that backslash comes from?
Also when I do a phpinfo(); the superglobal contents comes up correct for localhost and the ip_address... so I currently have no clue as to where that \ came from. As for the webserver i'm using, i'm currently using Apache 2.0.55.
Thanks
- hito
Code:
ob_end_clean();
header("Location: http://" . $_SERVER['HTTP_HOST'] .
dirname($_SERVER['PHP_SELF']) . "/index.php");
exit();
This code works perfect when i'm accessing it through http://localhost/current_page and it will redirect me back to http://localhost/index.php
However, if i'm accessing it through a ip address such as http://ip_address/current_page it will try to redirect me to http://ip_address\/index.php and of course that's a invalid url and it get the page cant be found issue.
I have not changed any code for this to happen, any ideas where or why that backslash comes from?
Also when I do a phpinfo(); the superglobal contents comes up correct for localhost and the ip_address... so I currently have no clue as to where that \ came from. As for the webserver i'm using, i'm currently using Apache 2.0.55.
Thanks
- hito