如何使用 modrewrite 进行重定向

发布于 2025-01-05 17:36:16 字数 330 浏览 0 评论 0原文

我在使用 mod 重写时遇到问题。 虽然我对它的使用知之甚少。 这是我的问题 我设置了当前的重定向规则

RewriteRule !(\.gif|\.png|\.jpe?g|\.css|\.js|\.php|^mr/.*)$ index.php [nocase,last]

,但它的作用是保留在index.php中,而网址中有一个/ 例如 mysite.com/about/ ...它将重定向到我的 php 代码中的 about.php ... 但我想要的是,如果文件夹存在,它应该转到该文件夹 如果该文件夹不存在,则应使用重写

i am having an issue working with mod rewrite.
although i have a very vague knowledge using it.
This is my issue
i have this current redirect rule set up

RewriteRule !(\.gif|\.png|\.jpe?g|\.css|\.js|\.php|^mr/.*)$ index.php [nocase,last]

but what this does is stay in the index.php while there is a / in the url
for example mysite.com/about/ ...which will redirect to about.php in my php code...
but what i want is if a folder exists it should go to the folder
if the folder doesn't exists it should then use the rewrite

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆光下的微笑 2025-01-12 17:36:16

把这个放在你的规则之上
RewriteCond %{REQUEST_FILENAME} !-d

Put this above your rule
RewriteCond %{REQUEST_FILENAME} !-d

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文