Solved

block root and subfolder using single .htaccess with deny/allow

Posted on 2011-09-06
4
1,324 Views
Last Modified: 2013-12-13
Is it possible to restrict access to the root folder and a sub folder using one .htaccess? Using deny/allow?

I have one .htaccess file in the root which has:

order deny,allow
deny from all
allow from 127.0.0.1
allow from 127.0.0.2

This blocks access to the root for all IP addresses other than 127.0.0.1 and 127.0.0.2

However I would also like to block a subfolder but I can't add another .htaccess file to any sub folders but I get internal server error if I have this:

order deny,allow
deny from all
allow from 127.0.0.1
allow from 127.0.0.2

<Directory "/xxxx/xxxx/xxxx/xxxx/domain.tld/images">
Options All
AllowOverride All
Order allow,deny
deny from all
</Directory>

Please advise
0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Expert Comment

by:parparov
ID: 36492453
What does Apache log say when you try to access that URL?
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 36517728
You get an error because the <Directory> container can only be used in the server config or <VirtualHost> container.  If you need a per-directory setting in an .htaccess file using Allow/Deny, you need to put that file in the target directory.

Another option is to use mod_rewrite.  The parent's .htaccess file will still be processed in the chain.  Something like this:

RewriteRule ^/?images(/.*)? - [F]

Open in new window

0
 
LVL 78

Expert Comment

by:arnold
ID: 36517820
You need to alter the order of your to allow, deny.
http://www.maxi-pedia.com/Order+allow+deny

If you are blocking/restricting access at the root, what additional restrictions are you placing down the road?

Where are you adding the extended directory?

use apachectl configtest to test the configuration file httpd.conf.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question