Forum Moderators: phranque
I have my domain on dedicated IP. When I try to visit subdomains of my site that do not exist, it shows the mirror of my home page. When I tried to contact the support staff, they told me it happens because my site is on dedicated IP.
For my other domains that are on shared IP, non-existent subdomains show me some control panel page instead of 404 error.
How can I solve this?
Thanks,
Vishal P. Rao
Welcome to WebmasterWorld!
There are a few things you can try if you want to get rid of the "duplicate domains."
1) Modify your DNS records, and disable "wild-card" DNS. This will prevent undefined subdomains from resolving to your IP address, and requests to those subdomains will return a DNS error.
2) Add some code to .htaccess in your Web root directory to redirect all undefined subdomains to your main domain.
3) Modify the code in step 2 to define a few subdomains for useful purposes. For example, you can create test.example.com as a subdomain of your site at www.example.com. You can use this domain to test new pages and code for your site on the "live" server.
Your DNS record probably looks something like this now:
ftp.example.com. IN A 192.168.0.1
smtp.example.com. IN A 192.168.0.1
*.example.com. IN A 192.168.0.1
or possibly even just:
*.example.com. IN A 192.168.0.1
If you change it to read:
ftp.example.com. IN A 192.168.0.1
smtp.example.com. IN A 192.168.0.1
www.example.com. IN A 192.168.0.1
Then only the "www.example.com" domain will resolve to your server for HTTP connections. (Be sure to make a copy of your existing DNS records before modifying them!)
Alternatively, you can put some mod_rewrite code into your .htaccess file to permanently redirect the "extra" subdomains to your main domain:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
The above is a quick overview, and you may run into problems I have not described here due to hosting restrictions. But these methods will work for many hosting setups, so you can try them and then decide on a solution that will work for you.
Jim