.htaccess使用一个查询字符串变量重写URL

时间:2015-09-29 12:00:05

标签: .htaccess mod-rewrite url-rewriting friendly-url

我正在尝试第一次重写URL,我有以下需要重写的URL:

http://domain.com/hotels/index.php?ct=new delhi

我想要这个

http://domain.com/hotels/hotels-in-new delhi

1 个答案:

答案 0 :(得分:0)

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /hotels/index\.php\?ct=(\S+) [NC]
RewriteRule ^ /hotels/hotels-in-%1? [R=301,L,B]  # Use QSD flag is Apache 2.4 or later

RewriteRule ^hotels-in-(.*)$ index.php?ct=$1 [L]