Welcome to WebmasterWorld Guest from 107.20.5.156

Forum Moderators: open

Message Too Old, No Replies

Should I use a 301 redirect?

     

hdpt00

8:35 am on May 11, 2004 (gmt 0)



If someone types my site in as domain.com or www.domain.com should I 301 redirect them to www.domain.com/?

Thanks,
Brandon

mcavic

3:50 pm on May 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you should. That will eliminate duplicate sites in the SE's.

bhartzer

4:50 pm on May 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mcavic is right, you should definitely use a 301.

hdpt00

7:22 pm on May 11, 2004 (gmt 0)



Now how exactly do I do this redirect in .htaccess so if they come to domain.com or domain.com/ or www.domain.com I send them to www.domain.com/?

Thanks,
Brandon

toolkit

7:39 pm on May 11, 2004 (gmt 0)

10+ Year Member



Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# rewrite to include www.
RewriteCond %{HTTP_HOST}!^www\.yourdomain\.com$
RewriteRule ^(.*)$ [yourdomain.com...] [R=301,L]

jdMorgan

7:53 pm on May 11, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The code above will not work if a visitor or a network cache appends a port number. Do not end-anchor the hostname.

Jim

hdpt00

10:14 pm on May 11, 2004 (gmt 0)



So then, what is the difinitve way to make sure it always goes to www.domain.com/? I'm not very good with this Apache stuff.

Thanks,
Brandon

mcavic

2:35 am on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is what I use:

RewriteEngine on
RewriteCond %{HTTP_HOST}!www\.domain\.com
RewriteRule ^/(.*) [domain.com...] [R=permanent]

Apache will handle adding the final / so you don't have to. It's true that it won't redirect someone who uses a port number on the end. But in general, nobody should be doing that.

jdMorgan

2:59 am on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



For use in .htaccess:

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

The leading slash on the RewriteRule pattern (as shown in the previous post) should be used only if your code is placed in httpd.conf; For use in .htaccess, leave it out.

You may or may not need the Options +FollowSymLinks directive. If this option is already configured, you won't need it. Otherwise, mod_rewrite won't work, and you should get an entry in your error logs complaining that FollowSymlinks or SymLinksIfOwnerMatch are not enabled. On some servers, users are not allowed to modify Options, so you may also get an error if you try to enable that Option. The only safe, reliable way to determine this on a live, busy server is to try it in an .htaccess file in a test subdirectory.

Jim

The_Hitcher

6:52 am on May 12, 2004 (gmt 0)

10+ Year Member



Except that Yahoo has a prob with 301's.....

mcavic

2:14 pm on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, but in this case, that's their problem, and duplicate listings will only increase one's traffic.

Laur

3:05 pm on May 12, 2004 (gmt 0)

10+ Year Member


What would be the behavior of Google if all my site links would be passed through PURL.ORG redirection service (HTTP 302)?

Ex. having

http://purl.org/MYNAMESPACE/* redirecting to
http://myvolatiledomainname/*

and all the links I use in the site have purl.org as base.

I would expect that the crawler would index the site (following 302) but report in results the purl.org URLs and not the temporary redirection URLs.

Is this correct?

(I hope I'm not off-topic.)

jdMorgan

3:18 pm on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Right now, all of your pages would end up as belonging to that domain instead of your own. If you value your domain name, do not do this. Use a 301 redirect, not a 302!

Jim

Laur

6:04 am on May 13, 2004 (gmt 0)

10+ Year Member



Great :)

That is what I'm looking for, to lock a resource in purl.org domain for creating a time persistent URL for it.

When I move the resource I will just update its redirect data on PURL. So SE can refer to it using the same address even I change domains, paths, etc.

Thanks.