LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   use htaccess higher up directory no symlinks? (http://www.linuxquestions.org/questions/linux-server-73/use-htaccess-higher-up-directory-no-symlinks-916734/)

qwertyjjj 12-02-2011 05:28 AM

use htaccess higher up directory no symlinks?
 
I have 3 folders for 3 different websites all with an admin folder that I currently block off IP addresses with via an htaccess file:

<Limit GET POST PUT>
order deny,allow
deny from all
allow from 109.150.55.xxx
</Limit>

linuxfolder/mysite.net/admin/.htaccess
linuxfolder/mysite.com/admin/.htaccess
linuxfolder/mysite.eu/admin/.htaccess

Each site runs different code and different databases so I cannot combine them.

How can I combine each of these htaccess files into 1 htacess file at the higher level domain linuxfolder so I don;t have to keep adding IP addresses into 3 individual files?

I do not have root access to the server so cannot use symlinks.

bathory 12-02-2011 04:46 PM

Hi,

I guess /path/to/linuxfolder is your docroot. If that's the case, you can use mod_rewrite in a .htaccess file in docroot, like this:
Code:

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/admin
RewriteCond %{REMOTE_HOST} !^109.150.55
RewriteRule (.*) - [F]

If you want to allow saccess to pecific hosts and not to the whole subnet, you can replace the 2nd RewriteCond with this
Code:

RewriteCond %{REMOTE_HOST} !^109.150.55.1
RewriteCond %{REMOTE_HOST} !^109.150.55.2

and so on

Regards

KernelJay 08-20-2012 09:10 AM

Be careful with that Limit Tag
 
qwertyjjj - I realize this response is a couple months late, but please note that there is some potential for this style of htaccess configuration to be bypassed. As outlined in the linked blog post, Apache may still hand off a request from those IPs if they use an HTTP method other than what you have specified in the Limit tag.

Read about it here: http://blog.ncircle.com/t5/VERT-Secu...-Tag/ba-p/4942


All times are GMT -5. The time now is 12:35 PM.