Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
the above works as far as removing .php from all of my urls. is it possible though to remove all parameters after the url if they exist? for example, rewrite site.com/index.php?id=24 to site.com/index
Add a
?after the %1:When there is a
?in the target URI of a rewrite rule, the rule won’t append the query string unless there’s aQSAflag.