RewriteRule ^articles\.php\?id=([0-9]+)$ article-a$1.html [R=301,L]
我希望所有链接像articles.php?id = 1211指向文章-a {ID} .html,我该如何实现?这条规则有什么问题?
答案 0 :(得分:3)
您无法在重写规则中与查询字符串匹配,您需要在条件中匹配%{QUERY_STRING}
var并使用%
反向引用:
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^articles\.php$ article-a%1.html [R=301,L]
答案 1 :(得分:-1)
Usefollowing,
RewriteRule ^articles.php?id=([0-9]+)$ article-a$1.html