无法在htaccess中获取查询字符串中的参数

时间:2014-07-16 07:36:58

标签: .htaccess

我的请求会像/insights/papers-articles.html?view=papers&p=10&/abcdefgh&indcal=1 当我点击这个网址时,它会将我重定向到/insights/papers-articles/papers-abcdefgh-3.html

我想要indcal参数,所以url将是/insights/papers-articles/papers-abcdefgh-10.html?indcal=1

我使用了以下规则:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&p=([^&\s]+)&/([^&\s]+)&indcal=([0-9]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html\?indcal=%6 [R=301,L]

但" indcal"参数未来,请帮忙。

TIA。

这是完整的规则

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&p=([^&\s]+)&/([^&\s]+)$ [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]


RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&p=([^&\s]+)&title=([^&\s]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]


RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&q=([^&\s]+)&/([^&\s]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]


RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&q=([^&\s]+)&title=([^&\s]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]


RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?p=([^&\s]+)&/([^&\s]+) [NC]
RewriteRule ^ /%1/%2/papers-%4-%3.html? [R=301,L]


RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&p=([^&\s]+)&/([^&\s]+)&indcal=([0-9]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html\?indcal=%6 [R=301,L]

最后一条规则适用于上述查询。

1 个答案:

答案 0 :(得分:0)

重新排列您的规则:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&p=([^&\s]+)&/([^&\s]+)&indcal=([0-9]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html\?indcal=%6 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&p=([^&\s]+)&/([^&\s]+)$ [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&p=([^&\s]+)&title=([^&\s]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&q=([^&\s]+)&/([^&\s]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?view=([^&\s]+)&q=([^&\s]+)&title=([^&\s]+) [NC]
RewriteRule ^ /%1/%2/%3-%5-%4.html? [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(insights)/(papers-articles)\.html\?p=([^&\s]+)&/([^&\s]+) [NC]
RewriteRule ^ /%1/%2/papers-%4-%3.html? [R=301,L]