简体   繁体   English

如何使用 .htaccess 或其他方式从网站 url 中删除 .php 扩展名

[英]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.我需要从我的网站 url 中删除 .php 扩展名。 I tried lots of code, but cant do it.我尝试了很多代码,但无法做到。 I used .htaccess in following way:我以下列方式使用了 .htaccess:

#remove php file extension-eg https://example.com/file.php will become https://example.com/file #remove php 文件扩展名-例如https://example.com/file.php将变为Z5E05651//example.com/8file4B7A6

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尝试使用此代码,看看它是否有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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