Php htaccess删除文件夹的文件扩展名

Php htaccess删除文件夹的文件扩展名,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我试过看其他教程和示例,但没有一个完全符合我的场景。我的htaccess文件如下所示: RewriteEngine on rewritecond %{http_host} ^example.com [nc] rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !\..+$ RewriteCond %{REQU

我试过看其他教程和示例,但没有一个完全符合我的场景。我的htaccess文件如下所示:

RewriteEngine on

rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) http://www.example.com/$1/ [R=301,L]

RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteRule ^view/([^/]+)/([^/]+)/?$ index.php?page=view&id=$1&title=$2

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([a-zA-Z0-9]+)
RewriteRule ^([a-zA-Z0-9]+)$ /%1/? [R=301,L]

ErrorDocument 404 /404
我正在使用PHP,需要重写/index.PHP?page=page&moreparmaters=1

但我在服务器上还有一个名为/admin/的文件夹,我想从该文件夹中的文件中删除.php扩展名,以便:

/admin/lol.php
变成
/admin/lol/

我有很多这样的文件,所以我不能单独添加每个文件。如何在不影响index.php重写的情况下执行此操作


谢谢

你得换个角度考虑。假设您的所有文件都直接放置在文件夹中(即没有子文件夹),这将起作用:

RewriteRule ^admin/([^\/]*)? /admin/$1.php [L,R]
在你的链接中,你可以写/admin/lol/或/admin/lol,两者都会被重定向到/admin/lol.php