How can I stop access using a domain name using htaccess?

I have multiple domain names pointing to a single directory. There is another domain that is also pointing to the accounts ip address. I want to stop the server from serving anything to the "other" domain.

Example:
a.com
www.a.com
b.com
www.b.com
All resolve to /home/person/public_html using one ip address

test.external.com
is resolving to this same ip address and the pages from a.com are being served.

I don't have any control over external.com, just my own apache server.

I want to use htaccess to stop all requests for test.external.com from serving a.com's pages. Preferably returning a 404 or other more relevant code for "does not exist".
LVL 6
austinstaceAsked:
Who is Participating?
 
Steve BinkCommented:
You can also use mod_rewrite to return a forbidden response:

RewriteEngine on
RewriteCond %{HOST}  ^other.example.com
RewriteRule  .* - [F]
0
 
giltjrCommented:
Well the easy way is not to use .htaccess.  Instead setup a name based virtualhost, create a document root for that named based virutal host and return a web page that says, this is no longer valid, please stop using.

Now, if you really want to use .htaccess then you would use rewrite and change the URL to one that does not exist.

Something like:

RewriteEngine on
RewriteCond %{HOST}  ^other.example.com
RewriteRule  http://other.exmple.com/doesnotexist.html

As a side note, you can lookup who owns that domain named and contact all/any of the contacts for that domain name inform them they the host name "xxxx.external.com" is pointing to an IP address that is allocated to you and you would appreciate it very much if they would change it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.