.HTACCESS - 将所有参数URLS(news.asp / id?= 1)重定向到同一页面

时间:2016-02-15 11:42:53

标签: .htaccess redirect parameters

您好我从以下旧网站获得了很多网址:

news_article.asp?id=51

我想发送所有网址,无论ID值是/news/

我已经尝试了以下但我得到了/news/?id=51

RewriteCond %{QUERY_STRING} ^id=51$
RewriteRule ^news_article.php /news? [NC,R,L]

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以将此规则用作站点根目录中的第一条规则.htaccess:

RewriteCond %{QUERY_STRING} (?:^|&)id=\d+(?:&|$) [NC]
RewriteRule ^news_article\.php$ /news/? [NC,R=302,L]
相关问题