Forum Moderators: phranque
I have a site set up at Powweb, but the morons there set everyone's DNS records up to allow "anything" - ie. the DNS CNAME record simply allows "*" ... even if you don't want it. Given that a simple request to them to change it to "www" goes unfulfilled, I thought I could probably handle it within an .htaccess file.
So, I want to allow [mydomain.com...] and [mydomain.com...] (ie. they should each go to the same place), but I want to disallow any machine names/ sub-domain names - for the present time at least.
Since the DNS record is not likely to be changed any time soon, then I figure that I should be able to get an .htaccess to allow the "www".domain.com (which is really just a sub-domain) - and any page underneath it - to do a re-write to domain.com (such that a 200 http code is issued), but do a redirect on anything else (ie. test.domain.com etc, etc). The redirect would go to the main page at domain.com, but at least a http error code (301?) would get issued such that it cannot be spidered...
So, I want [domain.com...] and [domain.com...] to work as you'd normally expect, but for any other sub-domains to get re-directed to [domain.com....]
Hope that makes sense ... any help appreciated.
Thanks.
Roy
Welcome to WebmasterWorld [webmasterworld.com]!
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
HTH,
Jim