2009-11-20 57 views
0

无法重定向动态URL。这是我想要完成的任务:htaccess重定向查询字符串并丢弃

Redirect 301 /content/index.php?id=423 http://www.domain.com/new-page/ 

我想这

RewriteCond %{QUERY_STRING} ^(([^&]*&)*)id=423$ 
RewriteRule ^content/index\.php$ http://www.domain.com/new-page [L,R=301] 

,但没有运气。谢谢! PS/ 我失去了一些对 工作与此代码

RewriteRule ^([^.]+)/([A-Za-z]*)-([^.]+)-([0-9]+).html$ $1/$4-$2-$3.html [L,R=301] 

回答

4

你需要指定替换URL查询。否则原来的查询次数:

RewriteCond %{QUERY_STRING} ^id=423$ 
RewriteRule ^content/index\.php$ http://example.com/new-page? [L,R=301] 

如果你想保留其他URL参数,试试这个:

RewriteCond %{QUERY_STRING} ^(([^&]*&)*)id=423&*([^&].*)?$ 
RewriteRule ^content/index\.php$ http://example.com/new-page?%1%3 [L,R=301] 
相关问题