Forum Moderators: phranque
/
/public_html/
/public_html/.htaccess
/public_html/index.php
/public_html/images/
/public_html/private/
/public_html/private/.htaccess
The .htaccess in the root directory has the following:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
As such when I go to mysite.com/images it goes directly to the folder
However when I go to mysite.com/private or mysite.com/private/
it redirects to my index.php file...
When I remove the .htacess file from the /private directory, everything works fine. So somehow, the root .htaccess is not seeing the /private as a directory.
Any ideas on how to correct this?
-Kerms
The problem seems like the -d directive is looking at /private and maybe seeing that it is protected... and is considering it to not be a directory?
the .htacess file in the private directory looks like this:
AuthType Basic
AuthName "Private Dir"
AuthUserFile "/home1/mysite/.htpasswds/public_html/private/passwd"
require valid-user
By itself this works... but when I added the .htacess file to the root I was no longer able to get into the /private/ directory because of the redirect.
But when I removed/renamed the .htacess file inside the /private/ folder it worked.... so something about nested .htacess files is causing it to ignore the -d directive and continute with the rewrite rule.
:(
[edited by: Kerms at 11:41 pm (utc) on May 24, 2008]
Add:
RewriteCond $1 !^private/
The only time I've ever had problems with -f/-d was when the %{REQUEST_FILENAME} was to be later rewritten. Therefore, -f couldn't find it, because the URL resolved to a non-existent file, since the URL hadn't been rewritten yet.
Jim
The requested dir DOES exist, but somehow the existance of the additional .htacess file inside it is messing things up. It also has something to do with the fact that it is requring the authentication because if I just put a .htacess file that doesn't require authenticantion, everything works fine.
Appreciate any and all ideas.
In the root directory of my site, I have both index.php and my .htaccess file...
THe rewrite condition was seeing my request to my private directory as a query to my index.php
I added
RewriteCond %{QUERY_STRING} ^/private$
And it resolved my issues.
Really appreciate all your input Jim!
[edited by: Kerms at 11:16 pm (utc) on May 25, 2008]
Turns out when it goes to /private it sees a 401 Error, Unauthorized access. Since I didn't have a default document setup for that error page so it when to index.php/401.shtml which got parsed by the rule and was accepted as not a valid file or directory!
Googled on that and I found: [andrewrollins.com...]
Added ErrorDocument 401 default to this and it resolved the issues all together!
I really appreciate your help as I don't think I would have gotten this far without your help!