使用.htaccess重写部分网址

时间:2015-08-25 14:36:54

标签: apache .htaccess mod-rewrite

我想重命名以下网址

http://xyz.website.com/search/sOrder,dt_pub_date/iOrderType,desc

http://xyz.website.com/search/sOrder,dt_pub_date/iOrderType,desc/category,111

http://xyz.website.com/index.php?page=search<&item=1&city=2...and so on>

http://xyz.website.com/index.php?page=search&sCategory=111<&item=1&city=2...and so on>

1 个答案:

答案 0 :(得分:0)

对于第一个重定向,这是一个快速解决方案(如果查询是静态的):

RedirectMatch permanent ^/(search/sOrder,dt_pub_date/iOrderType,desc).*$ /search/sOrder,dt_pub_date/iOrderType,desc/category,111

对于第二个:

RewriteCond %{QUERY_STRING} ^page=search(.*)$
RewriteRule ^index.php$ /index.php?sCategory=111%1 [R=301,L]

希望这会对你有所帮助。