I am just starting to use .htaccess files because I am on a shared hosting. I tried Google: much about creating a .htaccess file, little about where, how many, do rules cascade, etc.
Here is the map of my site:
/www.mysite.com
|
| .htaccess
| index.php
|
+---includes
| config.php
| functions.php
| some.class.php
| database.class.php
|
\---public
| .htaccess
| index.php
+---css
|
+---js
|
+---images
|
+---admin
index.php
I am putting the rule that redirects the root of the site (www.mysite.com) to the public folder in the .htaccess file that is located in the root.
RewriteEngine On
RewriteBase / public
In the .htaccess file that is located in the public folder, I am putting the rule that removes "/public/" from the URL (www.mysite.com/public/index.php ==> www.mysite.com/index.php).
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule (.*) /public/$1
I also have the following code to restrict access to the .htaccess file itself and to deny ditectory listings along with other (longer) code that denies bots, sets cache options, time zone, etc.
deny from all Options -Indexes -Multiviews
Do I only need to put that in root .htaccess file (does it trickle down like css)? Does it have to go in the public folder .hyaccess file too?
Do I need .htaccess files in ALL my folders (includes, js, etc.)?
In the includes folder .htaccess file I am putting the code:
<Files config.php>
Order Deny,Allow
Deny from all
</Files>
Is that the correct place for that?
Finally I will password protect the admin/index.php .htpasswd and .htaccess files. This is where I will add/delete users.
Any other recommendations are greatly appreciated.
Thank you in advance.