• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

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".
0
austinstace
Asked:
austinstace
1 Solution
 
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
 
Steve BinkCommented:
You can also use mod_rewrite to return a forbidden response:

RewriteEngine on
RewriteCond %{HOST}  ^other.example.com
RewriteRule  .* - [F]
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now