301 redirect - different method.

darrensss

Power Member
Joined
Jun 10, 2010
Messages
697
Reaction score
45
Hi.

When i normally set up a 301 redirect i use .htaccess .
This is going to be a problem for one reason or another so i need another way of doing it ...
I found this php way ...

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>


will this work? If i place this in the old page?
will google treat this in the same way it would if i did it via .htaccess?
 
It works exactly the same, a 301 is a 301.

This method is useful if you just want to redirect a single page because the code will only be called when that page is fetched; with the .htaccess method, the .htaccess file is parsed for every retrieval of every page on the site - so it means lower server load for a single page redirect.
 
Back
Top