How Do I Implement a 301 Redirect?
April 8, 2009
How Do I Implement a 301 Redirect?
- PHP (.htaccess) redirect
- ASP redirect
- ASP .NET redirect
- Windows redirect (IIS)
- ColdFusion redirect
- Canonical issues
PHP 301 Redirect (with a .htaccess File)
If the .htaccess file does not exist, create a new file with no trailing extension after the “.htaccess” using a plain text editor (Remember to put the period at the beginning of the file name!). For a Mac, we recommend BBEdit; for Windows, TextPad. Upload it to the root directory. Usually that’s in /public_html or /www on your server.
Add a new line that reads:
redirect 301 / http://www.new-site.com/
Or to redirect individual pages use the following as an example:
redirect 301 /old_page.html http://www.yourdomain.com/abc/new_page.html
In ASP:
Open the old web page and replace all its content with the following code, replacing “www.new-location.com” with the file name of the new page.
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.new-location.com”
%>
Entry Filed under: cms, open source, seo, smo. Tags: websites.
Trackback this post | Subscribe to the comments via RSS Feed