Thanks Brian, sorry for not being totally clear. What I want it to do is actually anything without a subdomain, to redirect to www.domain.com if it has a subdomain, it will be ignored. Good catch on the QSA.
how would you change the rule to match according to that objective? thanks ~Chad On Jan 19, 2011, at 1:00 AM, Bryan Petty wrote: > On Tue, Jan 18, 2011 at 2:19 PM, Chad Sollis <[email protected]> wrote: >> Hey there... to the tune of Wade's request yesterday, trying to make that a >> wildcard option, can anyone provide some insight, its not redirecting as >> desired :) >> >> RewriteCond %{HTTP_HOST} >> ^((?!\.).)*\.(com|net|org|ws|biz|ws|us|info|mobi|me)$ [NC] >> RewriteRule ^(.*)$ http://www.%1.%2/$1 [L,R=301] > > Are you really just trying to match _ANYTHING_ that doesn't have "www" > and redirect it to the "www" equivalent? That's what it looks like, > and you didn't explain how you want it to work. > > This seems like a really bad architectural decision if that's the > case, but if that's what you're going for, just check if it has the > "www" prefix, and if it doesn't, then redirect. Then, since you're > working towards such a wide matching constraint, you might as well > make sure it handles SSL and also query strings too, like so: > > RewriteCond %{HTTPS} =off > RewriteCond %{HTTP_HOST} !^www\. [NC] > RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301,QSA] > RewriteCond %{HTTPS} =on > RewriteCond %{HTTP_HOST} !^www\. [NC] > RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301,QSA] > > Regards, > Bryan Petty _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
