htaccess的mod-rewrite与子文件夹权威性发生冲突 [英] .htaccess mod-rewrite conflicting with subfolder auth
问题描述
我有一个网站,它把对文件/文件夹里面做使用的.htaccess不存在索引文件的所有请求:
I have a site which redirects all requests for files/folders which don't exist to an index file using .htaccess:
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule !admin/* index.php [NC,L]
有一个文件夹的admin /,它有在.htaccess用于身份验证以下内容:
There is a folder "admin/" which has the following in .htaccess for auth:
AuthType Basic
AuthName "admin"
AuthUserFile "/path/to/passwd"
require valid-user
添加了身份验证.htaccess文件管理/导致由mod-rewrite,而不是提供的认证响应被困请求。我试图努力解决这个(包括这几个不同的东西:<一href="http://stackoverflow.com/questions/1641666/htaccess-rewrite-and-auth-conflict">http://stackoverflow.com/questions/1641666/htaccess-rewrite-and-auth-conflict),但无法得到任何报价。
Adding the auth .htaccess file in "admin/" causes the request to be trapped by mod-rewrite instead of providing the authentication response. I've tried a few different things trying to work around this (including this: http://stackoverflow.com/questions/1641666/htaccess-rewrite-and-auth-conflict), but couldn't get any purchase.
感谢。
编辑::如果我已经通过验证,重写规则的和的让我进入管理/文件夹中。如此看来,这是身份验证的挑战,在做一些靠不住的。
If I'm already authenticated, the rewrite rule works allowing me to access the "admin/" folder. So it seems that it's the authentication challenge that's doing something wonky.
推荐答案
我有同样的问题,我也发现了此相关的问题:的 htaccess的重写和权威性冲突
I had this same question, and I also found this related question: htaccess rewrite and auth conflict
答案之一有避让我到我的问题。阿帕奇试图找到的401错误和失败的文档。我添加了一个文件/401.html,并已将此添加到.htaccess文件的验证语句。
One of the answers there clued me into my problem. Apache was trying to find a document for the 401 error and failing. I added a document /401.html and added this to the .htaccess file with the Auth statements.
ErrorDocument的401 /401.html
ErrorDocument 401 /401.html
现在,它为我的作品!
这篇关于htaccess的mod-rewrite与子文件夹权威性发生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!