-1

I want to create a subdomain that points to an outside IP address on my virtual hosted site. I created an A record in my DNS settings with the name of the subdomain I'd like, then I selected "A" record, and added the IP address of the site I'd like to redirect to.

When I go to the subdomain, it loads my main site as if it exists and the URL stays as the subdomain.site.com.

I then tried other subdomains that don't exist in my DNS settings to see if they would load, and they do.

doesntexist.site.com

...loads my site too. Can you help me understand what's going on?

Steve
  • 592
  • 9
  • 24

1 Answers1

0

Fixed by adding some rules in .htaccess:

# Redirect any non-existing subdomains
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^site\.com$ [NC]
    RewriteCond %{HTTP_HOST} !^excludedsubdomain\.site\.com$ [NC]
    RewriteRule ^(.*)$ http://ite.com/$1 [L,R=301]
</IfModule>

Though, still not sure why my excluded subdomain doesn't redirect to the new IP address I assigned.

Steve
  • 592
  • 9
  • 24