.htaccess 文件夹的drop.php扩展名-htaccess

.htaccess 文件夹的drop.php扩展名-htaccess,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,目前,我在URL中删除了.php扩展名 我使用: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^/]+)/$ $1.php # Forces a trailing slash to be added RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILEN

目前,我在URL中删除了.php扩展名

我使用:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php

# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
问题是,如果我有一个文件夹,它就不能工作。我必须将其添加到每个文件夹组。我知道有一个更简单的方法


有人能帮忙吗?

您只需要更改正则表达式,这样就不会排除包含
/
的请求

将第一条规则更改为:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.+)/$ $1.php

您只需要更改正则表达式,这样就不会排除包含
/
的请求

将第一条规则更改为:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.+)/$ $1.php

哇!非常感谢,哇!非常感谢。