How to prevent direct access to pointer/subdomain directory

Web programming topics
Post Reply
Tony
Lieutenant
Lieutenant
Posts: 86
Joined: Tue Jul 21, 2009 4:11 pm

How to prevent direct access to pointer/subdomain directory

Post by Tony » Sat Nov 28, 2009 6:33 pm

If you set up a domain pointer (or subdomain) using a directory that is created within your main domain directory, you can also get to the pointed site by using https://robot.lk/pointerdirectory. You can prevent this using the code below in a .htaccess file in your pointed domain directory. If you try to access the directory with the wrong domain name (not the pointer domain or subdomain) it will re-route the request back to requested domain name (the main domain).

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !robot.lk$
RewriteRule (.*) http://%{HTTP_HOST} [L,R]
Change robot.lk to your pointed domain name or subdomain name (from robot.lk).
Post Reply

Return to “Web programming”