Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess. deny root, allow specific subfolder. Possible?

Tags:

How can I deny access to http://sub.mydomain.com/, but allow for (completely) http://sub.mydomain.com/test (or http://sub.mydomain.com/test/)

There is a magento back-end behind http://sub.mydomain.com/test/

like image 274
V-Light Avatar asked Oct 04 '11 14:10

V-Light


People also ask

Does htaccess work on subdirectories?

You can add a . htaccess file to any directory that requires lenient permissions settings (such as 760, 766, 775 or 777). You can prevent the execution of scripts inside the directory and all its sub-directories.

What does htaccess Deny from all do?

htaccess to make it happen. For example, deny from all is a command that will allow you to apply access restrictions to your site.

Where is .htaccess located?

htaccess file is located in the root directory of your WordPress site. Depending on your hosting provider, the root directory may be a folder labelled public_html, www, htdocs, or httpdocs. You can locate it by using File Manager in your hosting account's cpanel. Let's walk through the process step-by-step.


1 Answers

.htaccess directives apply to that directory, and all subdirectories thereof, so you should disallow access in your DocumentRoot,

http://sub.mydomain.com/.htaccess:

Order deny,allow
Deny from all

And override that in any specific subdirectories you would like to allow access to,

http://sub.mydomain.com/test/.htaccess:

Order allow,deny
Allow from all
like image 91
nachito Avatar answered Nov 05 '22 10:11

nachito