2014-06-11 30 views
0

我有一些样本网址我需要改写:的.htaccess mod_rewrite的,其中包括查询字符串

RewriteCond %{QUERY_STRING} ^blue-spares-cycle-for-cancer-research$ [NC] 
RewriteRule ^news/news-item/?$ http://www.blue-group.com/en/news/ [R=301,L] 

RewriteCond %{QUERY_STRING} ^blue-spares-appoints-stuart-truckel-as-sales-director$ [NC] 
RewriteRule ^news/news-item/?$ http://www.blue-group.com/en/news/ [R=301,L] 

RewriteCond %{QUERY_STRING} ^project-manager-blue-machinery-london-ltd$ [NC] 
RewriteRule ^about-us/careers/careers-item/$ http://www.blue-group.com/en/about/careers/ [R=301,L] 

RewriteCond %{QUERY_STRING} ^000841:bakers-star-screen$ [NC] 
RewriteRule ^used-machinery/en/screeners/used-machinery-item http://www.blue-group.com/en/used-machinery/ [R=301,L] 

RewriteCond %{QUERY_STRING} ^000751:baler$ [NC] 
RewriteRule ^used-machinery/en/other/used-machinery-item http://www.blue-group.com/en/used-machinery/ [R=301,L] 

RewriteRule ^(.*)$ index.php/$1 [L] 

我的问题是我有很多相似的网址。我是否需要为每个人创建新的RewriteCond

而且我得到的结果是这样,例如:

http://www.blue-group.com/en/used-machinery/?000751:baler 
+1

原始如果你问有关合并(不只是'QSA '),然后查看一个'RewriteMap'。 – mario

回答

0

快速谷歌搜索变成了这样:

保留原始查询(默认行为)

RewriteRule ^page\.php$ /target.php [L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php?foo=bar 

放弃原来的查询(注意?目标后)

RewriteRule ^page\.php$ /target.php? [L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php 

替换原来的查询

RewriteRule ^page\.php$ /target.php?bar=baz [L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php?bar=baz 

追加新的查询到原来的查询(QSA在这里是关键)

RewriteRule ^page\.php$ /target.php?bar=baz [QSA,L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php?foo=bar&bar=baz 

here