We need to block a specific URL for anyone not on a local IP (anyone without a 192.168.. address)

We however cannot use apache's

<Directory /var/www/foo/bar>
Order allow,deny
Allow from 192.168

<Files /var/www/foo/bar>
Order allow,deny
Allow from 192.168

Because these would block specific files or directories, we need to block a specific URL which is created by mod-rewrite and the page is dynamically created using PHP.

Any ideas would be greatly appreciated


Probably you still can use

<Location /foo/bar>
Order deny,allow
Deny from all
Allow from 192.168
  • Should I be putting the URL before it was modified by mod-rewrite or the one the user sees in their browser? Thanks a lot by the way – Alex Feb 8 '11 at 22:42
  • I am not 100% sure, but I think you should put an original unmodified URL as it is in the browser. I think these directives are processed prior to invoking mod_rewrite handlers. – Alex Feb 8 '11 at 22:55

You can do this type of filtering with iptables. This does not work for HTTPS.

iptables -I INPUT -m string --string '/foo/bar' --algo bm -p tcp --dport 80 -j REJECT --reject-with tcp-reset

This is obviously hack style solution, but thats how i roll!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.