: Make all subdomains point to root unless otherwise specified I'd like all subdomains that aren't being used for anything else to go straight to my domain. ns1.mydomain.com. A 198.123.44.55
I'd like all subdomains that aren't being used for anything else to go straight to my domain.
ns1.mydomain.com. A 198.123.44.55
ns2.mydomain.com. A 198.123.44.66
*.mydomain.com. CNAME mydomain.com
webdisk.blog.mydomain.com. A 198.123.44.55
However, say I have subdomain blog.mydomain.com which I still want to behave as a normal subdomain. I would like the following to happen:
mydomain.com --> mydomain.com
mydomain.com --> mydomain.com
abc.mydomain.com --> mydomain.com
blog.mydomain.com --> blog.mydomain.com
Is this possible?
More posts by @Kevin317
2 Comments
Sorted by latest first Latest Oldest Best
If you are in a shared hosting with a single directory, you can use mod_rewrite in .htaccess to redirect all the subdomains to the root.
Adapted from: stackoverflow.com/questions/5966827/redirecting-multiple-domains-urls-to-one-canonical-domain.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example.com [NC]
RewriteCond %{HTTP_HOST} !^blog.example.com [NC]
RewriteRule ^/?(.*) example.com/ [L,R=301,NE]
Sure it's possible. But I think it's more about configuring Apache.
Define a wildcard vHost and one for the blog - load the blog-vhost first and afterwards the wildcard one.
Maybe this link is helpful for you: ma.tt/2003/10/wildcard-dns-and-sub-domains/.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.