rgb192
asked on
all subdomains go to non .htaccess
linux shared server
this is .htaccess code (i hope it is correct)
to have www. redirect to non www
sometimes I type wwwww.example.com or ww.example.com
could I have a rule where all subdomains forward to http://example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
this is .htaccess code (i hope it is correct)
to have www. redirect to non www
sometimes I type wwwww.example.com or ww.example.com
could I have a rule where all subdomains forward to http://example.com
ASKER
so every subdomain must be written?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Note that neither of these methods preserve query strings. If the site does not use query strings then this is no issue. If the site uses query strings then %{QUERY_STRING} must be appended to the target URL.
Now here is the catch. In order for this to work, the server must be either (a) non-vhost and accept any domain name at all, or (b) a vhost with the possible subdomain names explicitly accepted in the vhost definition. Otherwise the server will reject the request as "not for this site."
Open in new window