I use a .htaccess file to rewrite my urls to make them SEO friendly, this works fine. This file is located in the root (public_html). A website runs there too.
Now I created a directory named 'templates' which is CHMOD to 777. I want it to be protected so these files cannot be accessed from outside.
Through directadmin I protected that folder.
Now if I use my browser to surf on the website all the urls are still SEO friedly. However when I try to surf to that protected directory (templates) it shows a 404 page that I created but shows 401.shtml as title. If I look at the url it also shows 'domain.com/401.shtml/'.
It does not ask me for an username or password either.
Now if I delete or simply rename the htaccess file (to .htaccess2) which is located in public_html (the one that arranges all the SEO friendly urls) the pages on the website do not work (obviously) but now if I surf to that /templates directory, it does ask me for an username and password and I am able to login and access the files.
This is the htaccess file I use in the root:
RewriteEngine On
ErrorDocument 404 /home
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule ^(.*?)$ $1 [L]
RewriteRule ^(nl|NL|fr|FR|en|EN)/start\.html$ /$1/ [R=301]
RewriteRule ^([^/]*)$ /$1/ [R=301]
RewriteRule ^([^/]*)/$ index.php?page=$1 [L]
RewriteRule ^([^/]*)/([^/]*)$ /$1/$2/ [R=301]
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?page=$1&subpage=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /$1/$2/$3/ [R=301]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /index.php?page=$1&subpage=$2&subsubpage=$3 [L]
EDIT: I've noticed that when I turn the RewriteEngine Off in the main htaccess file it does work too (except for the rewrite of course). Any idea's?
I found this on the web which seems to work!
The problem is that accessing protected content makes Apache send a 401 header.
I had to put the following in the .htaccess file which was located in the protected directory.
ErrorDocument 401 "Unauthorized Access"
RewriteEngine off