.htaccess的查询字符串键重写而不会改变路径
问题描述:
我有这样一个URL:.htaccess的查询字符串键重写而不会改变路径
example.com/this/that.html?zona=my-zona
,我需要重写,并做了301:
example.com/this/that.html?loc=my-zona
我需要保持键'zona'的路径和查询字符串值相同,但我需要将'zona'键重写为'loc'
答
您可以在.htaccess顶部更改此规则:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^zona=([^&]*) [NC]
RewriteRule ^this/that\.html$ %{REQUEST_URI}?loc=%1 [L,NC,R=301]
@ neting.it:这是否工作正常? – anubhava