我想在 .htaccess 中使用 mod_rewrite 重写 URL,例如http://www.companysite.com/gallery.php?galid=1&desc=blah%20blah%20blah到http://www.companysite.com/画廊/1/blah-blah-blah
使用Loren给我 的粗略代码:
#Perform a 301 redirect from the old URL to the new URL
RewriteRule ^gallery.php?galid=([0-9]+)&desc=(.*) http://www.companysite.com/gallery/$1/$ [R=301,L]
#Rewrite new URL to the proper internal URL
RewriteRule ^gallery/([0-9]+)/(.*)$ ^gallery.php?galid=$1&desc=$2 [L]
如果查询字符串为desc
is blah%20blah%20blah
,将如何重写?理想情况下,我想desc
被改写为blah-blah-blah。我怎么做?