如何将附加 url 参数添加到我的 mod_rewrite 规则中

发布于 2025-01-02 17:37:36 字数 606 浏览 3 评论 0原文

好的,这就是问题所在,

我有大约 30 个左右的重写规则,如下所示:

    RewriteRule ^Frequently-Asked-Questions$ index.cfm?event=faqs-frequently-asked-questions 
    RewriteRule ^faq/([a-zA-Z0-9_-]+)/([0-9]+)$ index.cfm?event=faq&faqID=$2

所以这很好用,网址如下:

    www.example.com/Frequently-Asked-Questions

或 www.example.com/faq/why-wont-this-work/1234

完美运行。

问题是当我们尝试在其顶部添加 URL 参数时,那么

    www.example.com/Frequently-Asked-Questions?phoneNum=123-345-2322 doesn't work at all.

我如何在整个网站上普遍添加这些额外的 url 参数呢?

Ok so here is the problem

I have about 30 or so rewrite rules that look like this:

    RewriteRule ^Frequently-Asked-Questions$ index.cfm?event=faqs-frequently-asked-questions 
    RewriteRule ^faq/([a-zA-Z0-9_-]+)/([0-9]+)$ index.cfm?event=faq&faqID=$2

So this works great and urls like:

    www.example.com/Frequently-Asked-Questions

or
www.example.com/faq/why-wont-this-work/1234

Work perfectly.

The problem is when we try to add URL parameters on TOP of this, so

    www.example.com/Frequently-Asked-Questions?phoneNum=123-345-2322 doesn't work at all.

How can i add these extra url parameters universally across the site?

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

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

发布评论

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

评论(1

生活了然无味 2025-01-09 17:37:36

添加QSA &末尾有 L 标志。

标记 QSA Apache 文档
标记 L Apache 文档

RewriteRule ^Frequently-Asked-Questions$ index.cfm?event=faqs-frequently-asked-questions [L,QSA]
RewriteRule ^faq/([a-zA-Z0-9_-]+)/([0-9]+)$ index.cfm?event=faq&faqID=$2 [L,QSA]

add the QSA & L flag at the end.

Flag QSA Apache Docs
Flag L Apache Docs

RewriteRule ^Frequently-Asked-Questions$ index.cfm?event=faqs-frequently-asked-questions [L,QSA]
RewriteRule ^faq/([a-zA-Z0-9_-]+)/([0-9]+)$ index.cfm?event=faq&faqID=$2 [L,QSA]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文