homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

"www.yoursite.com" versus "yoursite.com" and redirects
does it help to rewrite all yoursite.com to www.yoursite.com

 2:18 pm on May 7, 2003 (gmt 0)

I've got two related questions:

1. Does it help to redirect all yoursite.com to www.yoursite.com? I notice that webmasterworld does it.

2. What is the appropriate rewrite command in the .htaccess file to do this universally/generally across the site with only a single rewrite rule in .htaccess? I've searched webmasterworld for an answer to this but keep finding more complicated scenarios than I'm dealing with. I don't want to redirect from an old site to a new site. I also don't want to redirect just a particular directory or file. I want to redirect all calls to site.com* to www.site.com*

Thanks for any help.



 2:05 am on May 8, 2003 (gmt 0)

Does it help to redirect all yoursite.com to www.yoursite.com?
Does it help WHAT? ;)

There is evidence that Google splits the page rank for a site that has incoming links pointing to both www.yoursite.com and yoursite.com which is why I use this type redirect on my sites.

AFAIK, you'll need at least two lines of code to implement this redirect. Also, it would be prudent to become a little familiar with .htaccess and mod_rewrite before trying this, there can be some "gotchas." This post [webmasterworld.com] will introduce you to them. The code you're looking for is already on the board in several places but perhaps someone will post it again for you.


 3:51 am on May 8, 2003 (gmt 0)

I've spent a lot of time with .htaccess, so becoming familiar is not an issue. I'm just having the hardest time finding or thinking of a solution to a general redirect. I've searched WebmasterWorld extensively and find much on .htaccess and redirects but none that give specific examples of a universal redirect from site.com* to www.site.com* .


 4:09 am on May 8, 2003 (gmt 0)

I do the reverse ... I redirect www.mysite.com to mysite.com ... but the same thought processes apply.

If your preferred form is the only URL that ever appears in your address bar, that improves the likelihood that other sites will link to you that way. It is A Good Thing to have your link pop focused on one form or the other, rather than split between the www. and non-www. versions. I don't think it matters which one you use as long your link pop is as consistent as possible.


 2:03 pm on May 8, 2003 (gmt 0)

Here's one solution:

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

We try to avoid redundant posts to keep WebmasterWorld as useful as possible but it's tough to search it all...


 5:20 pm on May 8, 2003 (gmt 0)

Thanks a whole lot. That worked on a first try.

BTW, as webmasterworld gets filled with more and more content (much of which is noise), have there been any plans to manually pull content out and highlight it somewhere on the site?

I've been using this site for a little over 1 year now, and have found it increasingly more difficult to find the information I need as the membership base and posting has gone up.

Just a thought.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved