Apache Server configuration support - Restrict access to localhost only

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2004 > Restrict access to localhost only





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Restrict access to localhost only
Jörg Ellermann

2004-08-23, 6:00 pm

I want to prevent access to a specific directory with a .htaccess file. Only the
local php module should be allowed to access that directory.

I've put a .htaccess file in the directory:

<Directory />
Order Deny,Allow
Deny from all
Allow from (server's address here)
</Directory>

but it does not seem to work, though. By the way, would "localhost" be a legal
address in this directive?

Thanks,
Jörg
Matt

2004-08-23, 8:49 pm

Jörg Ellermann wrote:

> I want to prevent access to a specific directory with a .htaccess file. Only the
> local php module should be allowed to access that directory.
>
> I've put a .htaccess file in the directory:
>
> <Directory />
> Order Deny,Allow
> Deny from all
> Allow from (server's address here)
> </Directory>
>
> but it does not seem to work, though. By the way, would "localhost" be a legal
> address in this directive?


Yes, localhost or 127 (as in 127.0.0.1)

<Directory />
Order Deny,Allow
Deny from all
Allow from 127
Allow from example.net
</Directory>

Consider keeping whatever files these are out of the document root, that
is, outside of public_html or whatever.

--
Matt


-----= Posted via webservertalk.com, Uncensored Usenet News =-----
http://www.webservertalk.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jörg Ellermann

2004-08-23, 8:49 pm

Matt wrote:

[vbcol=seagreen]
> Yes, localhost or 127 (as in 127.0.0.1)
>
> <Directory />
> Order Deny,Allow
> Deny from all
> Allow from 127
> Allow from example.net
> </Directory>


Thanks for answering. Although I've already found it - I didn't change the main
server config to allow .htaccess overrides.

BTW, after changing that, the above resulted in a sever error - <Directory> is
not allowed in .htaccess files.

Jörg
Jeppe Uhd

2004-08-24, 3:26 am

Jörg Ellermann wrote:
> Matt wrote:
>
>
> Thanks for answering. Although I've already found it - I didn't
> change the main server config to allow .htaccess overrides.
>
> BTW, after changing that, the above resulted in a sever error -
> <Directory> is not allowed in .htaccess files.


Well... Think of the .htaccess file as having an implicit "<Directory .>"
:-)

--
MVH Jeppe Uhd - NX http://nx.dk
Webhosting for nørder og andet godtfolk


Erik

2004-08-27, 6:35 pm


>BTW, after changing that, the above resulted in a sever error - <Directory> is
>not allowed in .htaccess files.
>


because .htaccess only works for the directory it is IN....


frgr
Erik
Erik

2004-08-27, 6:35 pm

On Tue, 24 Aug 2004 01:54:10 +0200, Jörg Ellermann
<j.ellermann@tu-bs.de> wrote:

>I want to prevent access to a specific directory with a .htaccess file. Only the
>local php module should be allowed to access that directory.
>
>I've put a .htaccess file in the directory:
>
><Directory />
>Order Deny,Allow
>Deny from all
>Allow from (server's address here)
></Directory>
>
>but it does not seem to work, though. By the way, would "localhost" be a legal
>address in this directive?
>
>Thanks,
>Jörg



watch out: .htaccess is read at each request, so can give a
degradation in performance.
So IMHO it is best used by the maintainer of the directory it is in.
The server owner should put all his stuff in httpd.conf, which is only
accessed on server startup.
..
frgr
Erik
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com