Categories
Wordpress

How to set up your .htaccess to allow only certain subdirectories

Until I update and reorganize my old projects, all of them are not available for the moment.

Thing is, most of my projects are, like this blog, subdomains of avanzartewebs.com.

So, how could I allow you to read my blog but not reaching for now the other projects?

Well, all my projects are under an Apache webserver  (another popular option is ngix , but my povider uses Apache), so I can use an Apache configuration file named .htaccess 

On my webserver, all my projects are just subdirectories of the public_html folder, which is the one that stores the things that will be public.

public_html has its own .htaccess but each project could have its own as well. Rules would be overrided depending on the case.

I found what I should do in stack overflow

https://stackoverflow.com/questions/7649794/htaccess-deny-root-allow-specific-subfolder-possible

The user nachito tells us what to do. I hope it helps:

.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