Reputation: 339
How I can show on browser url my php file without .php extension SO:
instead home.php
, just home
How to do that with .htaccess, what I need to write in this file?
Upvotes: 2
Views: 99
Reputation: 786289
put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]
Upvotes: 1
Reputation: 1627
You can achieve this like that:
RewriteEngine On
RewriteRule ^([^/]*)$ /$1.php [L]
Upvotes: 1