0

If I have multiple domains pointing to the same site.

If I have a domain called admin-domain.com

I only want to allow admin-domain.com/admin/

But disallow anything-else.com/admin/


Also this needs to be done with .htaccess

Also there is no actual admin directory, but there are many urls like ...com/admin/products/edit/54 because I am using the CakePHP framework which already uses htaccess for url's like this. I just want to limit admin access to 1 domain.

2 Answers 2

1

Edit the .htaccess file in the Cake webroot directory:

RewriteEngine On
RewriteCond %{HTTP_HOST} !=admin-domain.com
RewriteRule ^admin/.*$ - [F]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
1
  • This works thank you, is there a way to allow www.admin-domain.com also? thanks!!
    – JD Isaacks
    Feb 16, 2011 at 19:01
-1

If you wanted to add the www to this. You can use:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^http://(www\.)?admin-domain\.com
RewriteRule ^admin/.*$ - [F]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

Just remember, the referring agent can be spoofed. ;-)

1
  • Can you please expand your answer to explain why/how this code addresses the OP's question? Dec 18, 2014 at 1:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .