Mod_rewrite:将所有内容定向到一个 PHP 文件
我有这样的规则:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule ^(.*)$ index.php?req=$1
</IfModule>
如果我请求像 myhost/view/blah
这样不存在的目录,那么一切都会正常工作,但是当我在 URL 中输入一些现有目录时,例如 myhost/module
我被重定向到 module/?req=module
而不是停留在 module/
我做错了什么? 我需要将所有内容重定向到index.php(当然除了index.php)。
I have this rule:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule ^(.*)$ index.php?req=$1
</IfModule>
Everything works fine if I request non-existing directories like myhost/view/blah
, but when i enter some existing directory in the url like myhost/module
I get redirected to module/?req=module
instead of staying at module/
What am I doing wrong?
I would need something that redirects everything to index.php (except index.php, of course).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DirectorySlash
可能会导致此行为。尝试禁用它。DirectorySlash
could cause this behavior. Try to disable it.