
A friend of mine who is just starting out (Internet business) was asking me the other day about 301 redirects, www’s vs non-www’s in domain and the .htaccess file and how it all relates to what I do and SEO etc. Because of that, I wanted to post it here on this blog. I have posted this information in other places before, but wanted it here for any of the Dream Systems Media readers to have access to it.
For anyone who is serious about search engine optimization knowing about 301 redirects is a MUST. I searched and searched all over for the bottom line-tell me how to do it examples of the 301 redirects and found the information confusing.
What you need to know, and NOTHING more!
First: The code to get your non wwws always redirecting to the wwws is as follows:
Here’s the code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
(Make sure your Apache installation has mod_rewrite enabled.)
As long as your Apache installation has mod_rewrite enabled then you should be able to use this fix on almost any host.
Second: If you have any old page urls that are being replaced by new search engine friendly ones, but do not want to lose your page rank then heres the code for that:
redirect 301 /old/oldurl.html http://www.newurl/new.html
MAKE SURE you DO NOT include the http://www.whatever.com ONLY USE whats after the .com starting with the / or it will not work! Also make sure to only put ONE space in between everything!
There you go! That is as simple as it gets or at least as I can make it!
Remember why we do the 301 redirect:
Mainly for Google. Google does not like a bunch of error pages and if you have alot of 404 error pages that do not exist anymore (maybe after doing a redesign, or introducing new SEF naming conventions) then its harder for Google to crawl and you can lose the page rank the page has. With the 301 redirects you do not lose PR and you will not have to worry about duplicate content issues with your www and non wwws. That alone is worth doing it!
A side note it might be a great idea to have your web designer create a custom 404 error page so it directs people to something useful so you are not losing traffic just in case a page is forgotten in this process. I have found that people are more willing to give the site a second chance when they see a custom 404 error page that helps lead them to the place they might have been looking for!
Pingback: The 5 Minute SEO Site Audit Checklist | Search Engine People | Toronto
Pingback: SiteProNews: Webmaster News & Resources » Blog Archive » The 5 Minute SEO Site Audit Checklist
Pingback: The 5 Minute SEO Site Audit Checklist | News | Adsense Money Making Blog For Advice On Racking In The Cash With Adsense
Hi. What are non-wwws?
Pingback: Web design, SEO Site Audit Checklist | Custom Website Design - Web Links Directory - Software Development
Hi Mat,
I have a question about 301 redirects I have used on my site with the help of a plugin. I have made them no-follow but I am unsure if I am doing the wrong thing. I would really appreciate your advice.
I have ‘Debt Guides’ on the index bar with a list of the guides, all the sub-domains, listed as 301 redirects.
In my Google Webmaster tools, it shows as ‘warnings’. Should I remove these 301 pages?
I am not looking for a link, but I am looking for your advice, so if you would prefer to email me direct and not post my comment that’s ok with me.
James
James Williamss last blog post..A Debt Management Plan Can Help You Get Out Of Debt
Hi Mat,
Thanks for that info.
Have been meaning to do a couple of redirects for a while. This is the first straightforward explanation I’ve found.
I have one question, is the order of the code on the htaccess file important? For example I have a few IP addresses from habitual spammers blocked on my file. I’m going to redirect my non www’s and put in a couple of redirects, should they go at the beginning of the file or doesn’t it matter?
Dave.
If you had http://www.site.com/index.html and also http://www.site.com/index.php with both pages containing similar content – could this result in Google dropping your site down the listings. I was #1 for many different queries but now I am lucky to be in to 100. There was very little change to the site and this may be the reason for some of it – I am guity of that one!
Shanes last blog post..ShaneMcDonald.com
Good article. Thanks for the tip on #301-redirect, Mat.
Pingback: The 5 Minute SEO Site Audit Checklist | SEO Review
Pingback: The 5 Minute SEO Site Audit Checklist | Search Engine Optimization Tips
You helped me a lot with the 301 redirect code, Mat. I used it in my .htaccess file and it works like a charm.
good advice on the 404 pages. I use a free plugin that does something interesting. It provides a list of posts that the user might have been looking for, based on the keywords in the URL. It’s not too pretty, but it tries to be helpful.
Just to confirm – 301s do lose a little bit of link power – was confirmed by Matt Cutts of Google a few weeks/months back. Link for reference: http://www.seomoz.org/blog/how-to-reach-bloggers-ninja-style
Still, the amount of lost power is “negligible”, so not really worth worrying about, but thought it was worth pointing out!