I wish 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]


[update] I'm not able to publish to superuser.com for whatever reason, so please not close / move this there

Thanks Jean

You could try that one:

RewriteCond %{HTTP_HOST} ^(.+)\.domainname\.com
RewriteRule .* http://domainname.com/xx/index.html [R]

The problem should match any non-empty subdomain.

If you wish to pass the data about which subdomain was utilized towards the rerouted site, you'll be able to add %1 (the first regex match in the RewriteCond) towards the redirect, e.g.

RewriteRule .* http://domainname.com/xx/index.html?from_subdomain=%1 [R]