我正在尝试重写
[https://example.com/vehicles.php?id=42
至https://example.com/vehicles/brand/honda
以处理我的新URL更改而不影响SEO。 (即“ 42”应映射到“本田”)
我尝试过this。
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^vehicles.php$ ^vehicles/brand/honda$ [L,R=301] #to handle old URLs to new URL mapping
RewriteRule ^vehicles/brand/honda$ ^vehicles.php?id=42$ [L] #to handle URL to file mapping
但是它重定向到
https://example.com/root/site/%5evehicles/brand/honda$?id=42
,有两种错误。
/root/site
)感谢您为解决此问题提供的帮助。
行尾的字符?
从输出路径中删除查询字符串。
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^vehicles.php$ vehicles/brand/honda? [L,R=301]