apache - How can I redirect non-existing sub-domains to domain [using .htaccess] -


suppose, user (of website), types random, not-existing sub-domain name:

random.example.com 

is possible redirct them [main] domain:

example.com 

the issue that, if users type [or misspell] sub-domain name - currently, goes [404] error page. yet, have placed:

errordocument 404 http://example.com 

in .htaccess - but, not redirect. possible create kind of rewrite conditions/rules wildcard, such sub-domains not exist?

it seems sub-domains's vhost's document root pointing somewhere else, cannot this.

on other hand in main apache config, use serveralias directive catch more domains regular expressions or if can control default virtual host (the first usually), can use rewrite rules well.


Comments