I have been using the following code to redirect users to a domain for over 2 yrs.
Lets say a user will navigate to my-example.com the index page is a template that defaults to load a blog so the actual url is my-example.com/index.php?nid=blog however the the url to displaed in the browser is my-example.com/blog.
I’ve been using a .htaccess file with the below code to mask this url and make it more reader and SEO friendly: –
RewriteEngine On
RewriteRule ^blog(/)?$ /index.php?nid=blog [NC,L]
RewriteRule ^blog/([A-Za-z0-9-]+)(/)?$ /index.php?nid=blog&article=$1 [NC,L] # Handle product requests
In the index.php file I was using the below code to send users going to my-example to my-example.com/blog
if ($nid == "") {
header("Location: ./blog/");
}
This worked fine in php 4 (default for my host). However I need to use PHP 5 for my new site so have added AddType x-mapp-php5 .php to the top of the .htaccess so that Apache uses php 5 however this has nerfed my php header redirect.
Chrome and Firefox both give similar errors that the page isn’t re-directing properly in a way that will never complete – a redirect loop.
I have not changed the php in my template only added AddType and an include for new content. Anyone any ideas?
I’ve tried using a .htaccess redirect to ./blog but this seems to cause the same error.
You probably had register_globals on earlier.
Read nid from $_GET[“nid”] instead.