Wednesday 4 May 2011

PHP .htaccess redirect

I have been helping a neighbour of mine who is an Optician in Spalding, and he was trying to make sure that when people were searching for "Opticians in Spalding" they would make sure that the old pages on his website that were already listed in Google, would still link through to his new site that he's spent ages on.

Being a windows server man, I know how to do this in IIS, but as his new website is hosted on a linux server, it needed to be compatible with that. So anyway, I found out that you can do 301 redirects on Apache using a .htaccess file.

In this case, it was real simple, create a blank file called .htaccess and the place an entry for each for each file that needs redirecting, i.e:

Redirect 301 /HTML/Consultations.htm http://www.molsom.co.uk/eye-tests.htm

Excellent, and I now know that visitors to my local Optician in Spalding will still get there from any old bookmarks!

No comments:

Post a Comment