I've been attempting to restrict access to an internet connected apache instance. My router has a port forward to the machine that is running apache. Don't know if this makes a difference.

Anyway I want to restrict it to LAN access only for the moment, and I want to use htaccess so that later I can enable visitors based on specific IPs. It is a dev server that I want my clients to be able to remotely preview, but not anyone else.

I've tried the instructions here: http://corz.org/serv/tricks/htaccess.php which explain to do this

order deny,allow
deny from all
allow from 192.168.1

In my .htaccess file, but this doesn't work, I can still access it from outside the lan. I'm trying it from my phone's 3g and it works.

If I change the order to something like

Order Deny,Allow
Deny from all
Allow from 192.168.1

(remove the comma) as per the apache docs here: http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow and the page still allows access on my phone and on the local.

Any ideas?

  • Can you please post the contents of "error.log" so we can examine and pinpoint the issue?
    – U4iK_HaZe
    Aug 30, 2011 at 4:23
  • Or the access log if there aren't any errors. And don't "censor" any IP addresses if/when you do post them. They are the most important bit of this problem.
    – Ladadadada
    Dec 10, 2011 at 11:00

1 Answer 1


Check if you have AllowOverride All to make sure that your .htaccess is not ignored.

  • What config file should this be in?
    – Jason
    Aug 30, 2011 at 23:50
  • The <Directory> directive for your DocumentRoot in the main config file httpd.conf.
    – quanta
    Aug 31, 2011 at 2:11

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.