简体   繁体   中英

How do I remove .php extension from the website url using .htaccess, or another way

I need to remove.php extension from my website url. I tried lots of code, but cant do it. I used .htaccess in following way:

#remove php file extension-eg https://example.com/file.php will become https://example.com/file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
enter code hereRewriteRule ^(.*)$ $1.php [NC,L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Try with this code and see is it work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM