[英]Trying to remove .php extension using htaccess
Hello guys I am practicing how to change the .php extention in my php pages, no luck yet. 大家好,我正在练习如何在我的php页面中更改.php扩展名,还没有运气。 I am using WAMP 3.1.0 on a 64bit here the software versions in the WAMP
我在64位上使用WAMP 3.1.0,此处是WAMP中的软件版本
I have the rewrite_module turned on on the httpd.conf file I have this string "LoadModule rewrite_module modules/mod_rewrite.so" commented out and changed AllowOverride None to AllowOverride ALL. 我在httpd.conf文件上打开了rewrite_module,并已将此字符串“ LoadModule rewrite_module modules / mod_rewrite.so”注释掉,并将AllowOverride None更改为AllowOverride ALL。
Below is the screenshot of my folder structure 下面是我的文件夹结构的屏幕截图
here is my index.php file screenshot 这是我的index.php文件的屏幕截图
here is my htaccss screenshot 这是我的htaccss屏幕截图
You may try this to remove .php
extensions completely from your file and to avoid infinite loop : 您可以尝试这样做,以从
.php
完全删除.php
扩展名,并避免无限循环:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]
This code will work in Root/.htaccess, Be sure to change the RewriteBase if you want to place this to a htaccess file in sub directory. 此代码将在Root / .htaccess中起作用,如果要将其放置在子目录中的htaccess文件中,请确保更改RewriteBase。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.