【问题标题】:General rewrite rule for string with multiple parameters具有多个参数的字符串的一般重写规则
【发布时间】:2014-10-06 10:56:06
【问题描述】:

我有以下网址: mysite.co.uk/productdetails.asp?pid=434&cid= 在这种情况下, cid 没有值,但是我确实有一些确实包含值。

我有以下重写规则:

RewriteCondition %{QUERY_STRING} ^productdetails.asp?pid=([0-9]+)&cid=([0-9]+)
RewriteRule ^productdetails\.asp$ /index.php? [R=301,L]

因为我想要将带有这些参数的任何字符串重写为 index.php 如果我这样做,我会收到 404 错误

The requested URL /productdetails.asp was not found on this server.

欢迎任何帮助

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite


    【解决方案1】:

    QUERY_STRING 只能匹配没有REQUEST_URI 的查询字符串。

    RewriteCondition %{QUERY_STRING} ^pid=[0-9]+&cid=[0-9]+ [NC]
    RewriteRule ^productdetails\.asp$ /index.php? [R=301,L,NC]
    

    【讨论】:

    • 我有一个类似的问题将开始一个新的。你有时间介意看看吗?
    • 好的,我会尝试回答这个问题,只需将新问题链接放在 cmets 中即可。
    • 我有一个类似的问题将开始一个新的。我有时间你介意看看吗? stackoverflow.com/questions/26215599/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-17
    • 2013-01-24
    相关资源
    最近更新 更多