在.htaccess中更改以删除文件扩展名后,页面未找到错误


page not found error after changes in .htaccess for removing file extension

我对.htaccess行为非常陌生我正试图从php文件中删除扩展名,我将其添加到.htaccess文件中

RewriteEngine on
Options All -Indexes
RewriteRule ^([^/.]+)/?$ $1.php

它工作正常,但当我想打开管理员或试图打开任何文件夹时,它会显示www.mysite.com/admin/

Not Found
The requested URL /admin.php was not found on this server.

在我的网站根文件夹中没有任何admin.php页面。

帮助将不胜感激感谢

你能试试这种方法并告诉我它是如何为你工作的吗:

Options All -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}'.php -f
RewriteRule ^(.+)$ $1.php [L]