用于删除文件扩展名的.htaccess中的更改后页面未找到错误

时间:2014-11-05 09:14:31

标签: php apache .htaccess

我对.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页面。

帮助将会很感激 感谢

1 个答案:

答案 0 :(得分:2)

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

Options All -Indexes
RewriteEngine On
RewriteBase /

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