Mobile app version of vmapp.org
Login or Join
Kevin317

: 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

@Kevin317

Posted in: #Cname #Dns #Subdomain

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?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

2 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

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]

10% popularity Vote Up Vote Down


 

@Mendez628

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/.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme