htaccess从具有查询字符串的url重定向

时间:2013-10-07 22:13:07

标签: .htaccess redirect

当我对此网址进行数字处理时:

http://www.mydomain/search.php?page=1&order=ASC&contract=rent&new=

url应该重定向到

http://www.mydomain/rent/1

我尝试在.htaccess中添加此行,但没有成功:

Redirect http://www.mydomain/search.php?page=1&order=ASC&contract=rent&new= http://www.mydomain/rent/1

提前致谢!!!

1 个答案:

答案 0 :(得分:1)

添加这些行(但如果它不存在,你只需添加第一行):

RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=(\d+)&order=ASC&contract=rent&new=$
RewriteRule search.php /rent/%1? [L,R=301]