1

How can I remove the ".php" file extension from a URL in php, and replace question marks with slashes?

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^(.*)$ $1.php [NC,L]
Amit Kumar PRO
  • 1,222
  • 2
  • 15
  • 27
Dr. Nio
  • 9
  • 4
  • Does this answer your question? [Remove .php extension with .htaccess](https://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – Shanteshwar Inde Jan 03 '20 at 04:26

1 Answers1

0

Try this

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]