Forum Moderators: phranque
h*tp://fwww.my-domain.com/
RewriteCond %{HTTP_HOST} ^w [NC]
RewriteCond %{HTTP_HOST}!^www\.my-domain\.com
RewriteRule ^(.*)$ h*tp://www.my-domain.com/$1 [R=301,L]
Our info site is set to redirect send all domain.tld requests to www.domain.tld so outta curiosity I tried fwww.domain and abc.domain a moment ago.
I dinna get back our 404 page, only a generic 404 and the 'most recent error' list in our cpanel doesn't indicate the attempts were even made. Hopefully the answer you get will permit me to also capture any wwww's or fwww's or even learn a tad more of my own abc's.
Hopefully the answer you get will permit me to also capture any wwww's or fwww's or even learn a tad more of my own abc's.
I have controls on addresses, other than my "allowed" list, requesting files. Rather than change half a dozen "allowed" conditions around my site, I'm hoping to 301 this one bad URL, but so far my methods have failed.
> without changing the existing RewriteCond/RewriteRule?
Your existing code will only allow domain redirects if the requested hostname starts with 'w', so it can't redirect 'fwww'.
You can make a list of the subdomains you don't want to redirect, and then let the rest get redirected:
RewriteCond %{HTTP_HOST} !^developer\.example\.com
RewriteCond %{HTTP_HOST} !^test\.example\.com
RewriteCond %{HTTP_HOST} !^pre_release\.example\.com
RewriteCond %{HTTP_HOST} !^members\.example\.com
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(developer¦test¦pre_release¦members¦www)\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Also, you could stack redirects:
RewriteCond %{HTTP_HOST} ^.+www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Jim
<added>
However, looking at my conds/rules it seems I am over-complicating things a bit. Since I do not have any other sub-domains, and I "think" I want "anything" to forward to my real domain, why couldn't I just change this existing code:
RewriteCond %{HTTP_HOST} ^w [NC]
RewriteCond %{HTTP_HOST}!^www\.my-domain\.com
RewriteRule ^(.*)$ h*tp://www.my-domain.com/$1 [R=301,L]
RewriteRule (.*)$ h*tp://www.my-domain.com/$1 [R=301,L]