If you want to do mod_rewrite, you can check SERVER_NAME to block unauthorized domains:
RewriteEngine on RewriteCond %{SERVER_NAME} ^(www\.)?thiefdomain1\.example$ [OR] RewriteCond %{SERVER_NAME} ^(www\.)?thiefdomain2\.example$ [OR] RewriteCond %{SERVER_NAME} ^(www\.)?thiefdomain3\.example$ RewriteRule ^ - [F]
or
RewriteEngine on RewriteCond %{SERVER_NAME} !^(www\.)?yourdomain\.example$ RewriteCond %{SERVER_NAME} !^(www\.)?yourdomain-alias\.example$ RewriteRule ^ - [F]
If you have root privileges, you can also solve the problem with name-based virtual hosting as follows:
NameVirtualHost *:80 <VirtualHost 192.0.2.100:80> ServerName dummy <Location /> Order deny,allow Deny from all </Location> ... </VirtualHost> <VirtualHost 192.0.2.100:80> ServerName www.yourdomain.example ServerAlias yourdomain.example ... </VirtualHost>
The first definition of VirtualHost considered the default virtual host. If 192.0.2.100 is available as the thiefdomain1.example file, the thiefdomain2.example file, thiefdomain3.example file, or any other hostnames other than www.yourdomain.example or yourdomain.example (defined in the second VirtualHost ), Apache refers to the first VirtualHost and returns 403 Prohibited status.
yasu
source share