What is a 301 Redirect?
A 301 redirect is a method of telling web browsers and search engines that a web page or site has been permanently moved to a new location. Web browsers will usually follow 301 redirects without the need for user action.
When should a 301 Redirect be used?
A 301 redirect should be used whenever a website is moved to a new domain name or whenever a webpage has been renamed or relocated so that search engines will quickly update their database and thus preserve the search engine rankings of the site or page.
How do I issue a 301 Redirect?
It’s pretty simple really
First, edit your website’s .htaccess file. If you don’t have an .htaccess file yet, just create a new one. Note the filename it’s “.htaccess” with the dot included.
Next, add the following code at the bottom of your .htaccess file:
redirect 301 someoldpage.html somenewpage.html
Simple, right? I told you. Here’s a simple explanation of what we just did:
redirect 301 - the instruction that the site or page has permanently moved
someoldpage.html - the old webpage
somenewpage.html - the new webpage
All you need to change here are someoldpage.html and somenewpage.html
To redirect an entire site to a new domain
redirect 301 / http://www.newdomain.com/
To redirect an entire folder to a different folder
redirect 301 /someoldfolder /somenewfolder
To redirect some file from on your old domain to some file on a different domain
redirect 301 /some/old/file.html http://www.newdomain.com/file.html
Need more examples and detail? Visit the Guide to Applying 301 Redirects in Apache.
There ya go! Enjoy!
April 2nd, 2007 at 7:45 am
Have you checked out RedirectMatch 301? Its the same as Redirect 301, except it lets you do pattern matching and replacing.
So you can redirect all posts that start with /2006/(.*) to /$1 cool!
April 2nd, 2007 at 7:53 am
Looks nice.