I tried to remove PHP extensions from my site. When the user requests a PHP file, PHP will be deleted and the user will be redirected, and when the user will enter the URL without PHP, the actual PHP file will be served. This works well unless the URL has a GET parameter. My rules are as follows:
RewriteCond %{THE_REQUEST} (\.php\sHTTP/1)
RewriteRule ^(.+)\.php$ /$1 [R=301,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ /$1.php [L,QSA]
I thought it should already be possible to remove php, even if there is any GET parameter, but it failed. I also tried something like this:
RewriteCond %{THE_REQUEST} (\.php\sHTTP/1)
RewriteRule ^(.)\.php(.)$ $1$2 [R=301,L,QSA]
It also did not work, php still exists. But if I try:
RewriteRule ^(.)\.php(.)$ $1$2 [R=301,L,QSA]
those. RewriteCond removal, php extension is removed and the settings are saved, but the page will not be displayed as the browser says there were too many redirects.
, ,