julien_simon
03-17-2011, 06:06 PM
Hey guys,
Do you know what the best way is to do a 301 redirect from a www. version to a non www.version without using htaccess? I have a site on a windows machine.
A programmer friend suggested:
1. Convert all .htm pages to .php pages
2. Convert all internal links to point to .php pages not .htm pages
3. Add this php code to the top of every page (before the <doctype> and <html> tags):
if (substr($_SERVER['HTTP_HOST'], 0, 4) === 'www.') {
header('Location: http'.(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : ''). '://' . substr($_SERVER['HTTP_HOST'], 4) . $_SERVER['REQUEST_URI']);
exit;
}
but she is not willing to do that. Moreover, she is on a windows machine so it may not even work.
Any ideas, suggestions?
Do you know what the best way is to do a 301 redirect from a www. version to a non www.version without using htaccess? I have a site on a windows machine.
A programmer friend suggested:
1. Convert all .htm pages to .php pages
2. Convert all internal links to point to .php pages not .htm pages
3. Add this php code to the top of every page (before the <doctype> and <html> tags):
if (substr($_SERVER['HTTP_HOST'], 0, 4) === 'www.') {
header('Location: http'.(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : ''). '://' . substr($_SERVER['HTTP_HOST'], 4) . $_SERVER['REQUEST_URI']);
exit;
}
but she is not willing to do that. Moreover, she is on a windows machine so it may not even work.
Any ideas, suggestions?