【发布时间】:2015-02-19 23:37:33
【问题描述】:
我整天都在寻找解决我遇到的问题的方法,并找到了许多建议的解决方案,尽管它们都没有奏效。我设置了 url 重写,除了一个文件夹外,一切正常。如果存在文件夹或文件,请不要重写,否则将其发送到 index.php 中进行处理。出现问题的一个子文件夹受密码保护。受密码保护的文件夹被重新写入 index.php,就好像子文件夹无效一样。其他子文件夹工作正常,并且其中没有 .htaccess。文件夹结构和 .htaccess 下面。
包含相关文件的文件夹结构
- public_html(根)
- 字体
- 图片
- js
- CSS
- 电子邮件
- .htaccess
- index.php
- .htaccess
- index.php
public_html/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]
public_html/email/.htaccess
AuthType Basic
AuthName "email"
AuthUserFile "/home/site/.htpasswds/public_html/email/passwd"
require valid-user
我尝试关闭电子邮件文件夹内的重写以防止在此解决方案中传播的重写表单没有明显效果。
## turn off rewrite engine
RewriteEngine off
AuthType Basic
AuthName "email"
AuthUserFile "/home/site/.htpasswds/public_html/email/passwd"
require valid-user
我还尝试过滤掉根 .htaccess 中的文件夹,这似乎也被忽略了,没有明显区别。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^email
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
对此的任何帮助将不胜感激!
2015 年 2 月 23 日更新:上午 11:20(美国东部时间)
我注意到的一件事是,如果我禁用 url 重写并对文件夹进行身份验证,然后重新启用重写,一切都会按预期工作。它似乎只有在您尚未通过身份验证时才会发生。
【问题讨论】:
标签: php apache .htaccess url-rewriting