PDA

View Full Version : 301 redirects


JustOneUK
8th February 2006, 01:29
I have seen a few different ways to write 301's.... anyone got an OFFICIAL version? which way do YOU write it?

TIA......

DuaneJackson
8th February 2006, 03:01
All depends on what language you use.

GaryReid
8th February 2006, 13:49
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)

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

The second using a rewrite rule:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]
[/code]

JustOneUK
8th February 2006, 15:26
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. :?

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

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

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

TIA....

James

JustOneUK
9th February 2006, 14:25
:shock:

GaryReid
9th February 2006, 14:33
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.

webit
9th February 2006, 15:23
A really good book is the O'Reilly Apache book. Overuse can slow your server down though.

JustOneUK
9th February 2006, 15:38
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. :(

webit
9th February 2006, 15:43
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.

JustOneUK
9th February 2006, 16:04
I have emailed them and just got the automated reply...pages are removed as our spider indexes the web...

perhaps i will try going thru the adsense publisher channels...

DarrenC
9th February 2006, 17:25
James, put all of the URL's you want removing out of Google into your robots.txt, and then click here (http://services.google.com:8882/urlconsole/controller?cmd=reload&lastcmd=login) 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

JustOneUK
9th February 2006, 19:07
LMAO! ... cheers Darren..

There is 22,000 pages I want removed.. that'll be some list :) woohoo

DarrenC
10th February 2006, 08:34
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

webit
10th February 2006, 08:39
Darren - Did you get your theShoppersBible.com code?