如何改进 htaccess 中的简单 mod_rewrite?

发布于 2024-09-30 09:30:22 字数 385 浏览 0 评论 0原文

我正在使用 mod_rewrite 来获取干净的网址,但我只是遇到了一个小问题。

该行特别是:

RewriteRule ^events/(.*)$ fe_events.php?event_url=$1

这有效。我可以访问 url.com/events/something_or_other ,它会按预期工作。然而问题是,如果我只是访问 url.com/events ,它就不起作用 - 我必须访问 url.com/events/ (末尾有一个正斜杠)。

我可以简单地修改这一行还是需要添加另一行,例如:

RewriteRule ^events$ fe_events.php

感谢您的时间!

I am using mod_rewrite for clean urls but I'm just having a small problem.

The line in particular is:

RewriteRule ^events/(.*)$ fe_events.php?event_url=$1

This works. I can go to url.com/events/something_or_other and it works as expected. The problem however is then if I just go to url.com/events it doesn't work - I've got to go to url.com/events/ (with a trailing forward slash on the end).

Can I simply modify this line or do I need to add another line such as:

RewriteRule ^events$ fe_events.php

Thanks for your time!

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

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

发布评论

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

评论(1

乖乖 2024-10-07 09:30:22
RewriteRule ^events(/(.*))?$ e_events.php?event_url=$1

这应该有效。

RewriteRule ^events(/(.*))?$ e_events.php?event_url=$1

this should work.

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