mod_rewrite 适用于 '/test',但不适用于 '/'
.htaccess 文件中的以下代码行为不正确。
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /test/$1 [L,QSA]
上面的代码将正确地将对“domain.com/uri-here”的请求发送到“/test/”目录。但是,对“domain.com/”的请求是不匹配/路由。
我不确定环境是否存在问题,尽管似乎是由于在另一台服务器上运行相同/相似的代码而导致的。
我做错了什么?
提前致谢!
The following code inside an .htaccess file is behaving incorrectly..
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /test/$1 [L,QSA]
The above will correctly send requests to 'domain.com/uri-here' to the '/test/' directory.. However, requests to 'domain.com/' are not matched / routed.
I'm unsure if there's an issue with the environment, though it seems so due to same / similar code working on another server.
What am I doing wrong?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/
可能与RewriteCond %{REQUEST_FILENAME} !-d
匹配/
is likely matching againstRewriteCond %{REQUEST_FILENAME} !-d