我想重定向永久301:
https://www.toto.com/index.php?id=4
到
https://www.toto.com/?id=4
这可以吗? =>
RewriteRule index.php?id=([0-9]+)$ /?id=$1 [L,NC,R=301]
谢谢!
答案 0 :(得分:1)
您无法匹配查询字符串,即?
及其后的RewriteRule
中的一部分。
您可以使用以下规则从所有路径中删除index.php
,但保留查询字符串:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]