Reputation: 376
i would like redirect permanent 301 :
https://www.toto.com/index.php?id=4
to
https://www.toto.com/?id=4
this could be fine ? =>
RewriteRule index.php?id=([0-9]+)$ /?id=$1 [L,NC,R=301]
Thanks !
Upvotes: 0
Views: 46
Reputation: 786291
You cannot match Query String i.e. ?
and part after that in RewriteRule
.
You can use following rule to remove index.php
from all paths but keep query string:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]
Upvotes: 1