Anything.DomainName.com redirect to DomainName.com/xx/test.html using .htaccess
I want to redirect WildChar.DomainName.com to DomainName.com/xx/test.html using .htaccess
.htaccess code is
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^\.DomainName\.com
RewriteRule ^(.*)$ /xx/index.html [L]
</IfModule>
[update] I am unable to post to superuser.com for some reason, so please do not close /开发者_如何学运维 move this question there
Thanks Jean
You might try this one:
RewriteCond %{HTTP_HOST} ^(.+)\.domainname\.com
RewriteRule .* http://domainname.com/xx/index.html [R]
The condition should match any non-empty subdomain.
If you want to pass the information about which subdomain was accessed to the redirected site, then you can add %1 (which is the first regex match from the RewriteCond) to the redirect, e.g.
RewriteRule .* http://domainname.com/xx/index.html?from_subdomain=%1 [R]
精彩评论