301
Protect Client Search Engine Placement with 301 Redirects
This is a big win for us web developers. It helps maintain all the SEO work that has gone into a site, and lets us move site architecture around with minimal impact.
Many times I run across companies whose website just went from ASP/CFM/JSP/PHP/CGI/HTML/HTM to ASP/CFM/JSP/PHP/CGI/HTML/HTM. Fill in the blank, migrating from one platform to another is a big deal. To make matters worse, how is a search engine supposed to know NOT to link to an old file, and to redirect the same relevancy to the new file?
The magic of 301 Redirects
301 is an HTTP Status code (just like 404 and others, 403, 500, etc).
301 tells browsers and search engines that a page has been “Moved Permanently”
How can you do a 301 redirect?
First off, do NOT attempt redirecting unless you know specifically what to do. Trying to implement a meta-refresh tag will hurt you more than it will help. Search engines have become wise to the meta-refresh game that spammers have been involved with. Do not do it.
There are 2 routes to take, server side, and code side.
Server Side 301 Redirects
If you’re lucky enough to be working on a server supporting .htaccess files, your life is easy.
- Create a file called “.htaccess” in the root of your website
- Open the file in a text editor
- Set the contents to the following (replacing original, and new):
Redirect 301 /original/original.html http://www.yoursite.com/new/new.html
RedirectMatch 301 (.*)\.htm$ http://yoursite.com$1.html
- In IIS (internet services manager), right click on the old file
- Select “a redirection to a URL”
- Enter the URL for the new page
- Select “The exact URL entered above” and “A permanent redirection for this resource.”
- Click “Apply”
| PHP | header( "HTTP/1.1 301 Moved Permanently" ); |
| ASP | response.setStatus(301); |
| JSP | response.setContentType("text/html"); |
HttpServletRequest req1=(HttpServletRequest) request;
StringBuffer ReqUrl= req1.getRequestURL();
String RequestUrl=ReqUrl.toString();String source;
String str; source = RequestUrl;
str = source.substring(0, source.indexOf(".jsp"));
response.setContentType("text/html");
response.setDateHeader("Expires", 0);
response.setHeader("Location", str+".php");
response.setStatus(301); Please share, it makes me happy:
Subscribe to Email Alerts
Make a Donation
Popular Posts
Follow Me
Recent Posts
Archives
Tags
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Johan Brook: Designer and Developer
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Woork
- zupko.info
