301 redirects

Depends what you are trying to achieve, are you looking to redirect a single page/site or redirect non www to www for search engine integrity?

Both can be implemented in .htaccess for apache servers, the first being the simple redirect statement (remember the trailing slash if no filename)

Code:
redirect 301 /youroldfile.html http://www.you.com/yournewfile.html

The second using a rewrite rule:

Code:
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^yoursite.com [NC] 
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]
[/code]
 
Upvote 0
it's for a non www rewrite on apache... these are the 3 I have seen so far, all have subtle differences.... I am trying to get 22,000 NON WWW pages de-indexed...but it doesn't seem to want to remove them. :?

Code:
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Code:
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]

Code:
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com
RewriteCond %{SERVER_PORT} ^80
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

TIA....

James
 
Upvote 0
A lot depends on how the servers main httpd.conf is setup, whether you need to use the 'on' switch, most likely you will and whether you need to use follow symlinks, again most likely you will.

Lastly it is possible at server level to stop certain functions within .htaccess, your host may have done this.
 
Upvote 0
I have one in place...

if you go to justoneuk.com it will redirect you to the www version, so it appears to be working.... but google is not taking out the non www pages out of it's index...and it should. :(
 
Upvote 0

webit

Free Member
Jul 13, 2005
1,124
7
Brighton, UK
JustOneUK said:
I have one in place...

if you go to justoneuk.com it will redirect you to the www version, so it appears to be working.... but google is not taking out the non www pages out of it's index...and it should. :(

That does take time (but I think you can email them and request it). The problem is that if they dont and you have www and non www pointing to the same page Google sees it as duplicate content and takes it out (or ignores it at least) from the index.
 
Upvote 0
James, put all of the URL's you want removing out of Google into your robots.txt, and then click here and within 5 days they will be gone forever..

Just makesure that your robots.txt file doesn't contain any files that you want to remain in Google, but not in other SE's.

It works a treat.

Darren
 
Upvote 0
Are these dynamic pages or HTML pages?

Either way that is the quickest way of getting rid - I had over 3,000 pages that were dynamic PHP pages that I had done a mod rewrite for to HTML, and Google spit all 3,000 pages out of it's database within 24 hours - nowadays though it's 5 days turnaround.

Don't believe all the crap about emailing Google to ask them - they will just dump your email.

Darren
 
Upvote 0

Latest Articles

Join UK Business Forums for free business advice