homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

how to do 301 direct ww. to www.

 9:00 pm on Apr 9, 2012 (gmt 0)

I am using an seo software and it found lots of duplicate content on my site. I checked and it seems i have my site with 2 W's and 3 W's(ww.mysite.com and www.mysite.com).
I have the below redirect for non www to www. Does anybody know how i should add on for ww to www? Thank you

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.com [NC]
RewriteRule ^(.*)$ [mysite.com...] [L,R=301]



 9:34 pm on Apr 9, 2012 (gmt 0)

You need to turn your code around. Pick the canonical name, and redirect everything that doesn't use that name. For example

RewriteCond %(HTTP_HOST} !(^www\.example\.com$)?

(I tend to mistype this, so you will want to search some nearby threads if nobody comes along and says She got it wrong again!!)

But the ww. worries me. In fact it's in my browser's boilerplate:
Did you make a mistake when typing the domain? (e.g. "ww.mozilla.org" instead of "www.mozilla.org")

If ww. works at all, it implies that you've got wild-card subdomains, so you can't do a universal redirect.

(Aside: I experimented. The first Big Name Domain that I intentionally mistyped, I got redirected to


ww.apache.org got the browser boilerplate. ww.google.com got... Ooh, cool picture. Who the deuce is Eadweard J. Muybridge and why couldn't his parents spell? Riveting picture, though.)


 9:39 pm on Apr 9, 2012 (gmt 0)

if this is an issue of wild-card subdomains, how do you think the best way to handle it is?


 12:16 am on Apr 10, 2012 (gmt 0)

Who the deuce is Eadweard J. Muybridge

Leland Standford paid Muybridge very well to prove that a trotting horse's four feet (hooves) were off-the ground simultaneously.
Leland Standford also paid for the publication of the book, which included many photographs of from the cameras setup on the Stanford's the Palo Alto Farm (a portion of which to day is Standford University.
Unbenownst to Stanford, Muybridge filed copyrights on the book. As Stanford became aware of the copyright and Muybridge refused to compromise, Stanford held the majority of the books in a warehouse and they were never released.

To give you an idea of Muybridge's loyalty.
Prior to the book/photo deal Muybridge had murdered his wife's lover and claimed temporary insanity under suggestion of Stanford's attorneys and Stanford's paid fees.
Muybridge was exonerated to later misjudge Stanford ;)


 1:54 am on Apr 10, 2012 (gmt 0)

if this is an issue of wild-card subdomains, how do you think the best way to handle it is?

You'll have to compromise. Your preferred form is with-www, right? Then something like

%{HTTP_HOST} ^(ww?\.)?example\.com(:\d+)?$

to encompass

w.example.com (heck, may as well include it!)

and also anything with that pesky port number stuck to the end. I don't think a request for .example.com with leading dot would reach you, so you don't need to allow for that possibility. (I just repeated my previous experiment with a couple of sites that do redirect misspelled urls, and all I got was the browser saying "Ain't no such place".)

That letter w is disorienting isn't it? I keep wanting to add an escape slash \ to make it into a word character \w.

Wilderness, you still out there? Got an idea you know the answer to this one. Does Apache support the {,2} form? As in w{,2} meaning "from zero to two w's".

Come to think of it, stinky, do your subdomains have a minimum length? If they have to be at least three characters long, then you've got it made. That way you really could say

^\w\w?\.example\.com et cetera

to redirect everything that's too short to your default www.

Now, there's one more thing you need to do. You can expect the occasional typo, but if you have a lot of ww.example.com requests, you'd better fine-tooth-comb your own site and make sure you don't have any misspelled internal links. Also check any external links that you've got control over.


 8:22 pm on Apr 11, 2012 (gmt 0)

lucy24 the redirect with the w's works perfect now. Thank you

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