Welcome to WebmasterWorld Guest from 23.22.140.143

Forum Moderators: open

Message Too Old, No Replies

Should I use a 301 redirect?

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

Senior Member

joined:Apr 2, 2004
posts:737
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 0


Yes, you should. That will eliminate duplicate sites in the SE's.
4:50 pm on May 11, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 28, 2003
posts:1977
votes: 0


mcavic is right, you should definitely use a 301.
7:22 pm on May 11, 2004 (gmt 0)

Senior Member

joined:Apr 2, 2004
posts:737
votes: 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

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

Junior Member

10+ Year Member

joined:Apr 6, 2003
posts:74
votes: 0


Options +FollowSymLinks
RewriteEngine on
RewriteBase /

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

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


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

Jim

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

Senior Member

joined:Apr 2, 2004
posts:737
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 0


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.

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


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

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

Junior Member

10+ Year Member

joined:Jan 13, 2003
posts:78
votes: 0


Except that Yahoo has a prob with 301's.....
2:14 pm on May 12, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 0


Yeah, but in this case, that's their problem, and duplicate listings will only increase one's traffic.
3:05 pm on May 12, 2004 (gmt 0)

New User

10+ Year Member

joined:May 12, 2004
posts:3
votes: 0

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.)

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


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

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

New User

10+ Year Member

joined:May 12, 2004
posts:3
votes: 0


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.