Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 更改.htaccess以删除文件扩展名后,未找到页面错误_Php_Apache_.htaccess - Fatal编程技术网

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

Php 更改.htaccess以删除文件扩展名后,未找到页面错误,php,apache,.htaccess,Php,Apache,.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. 在我的网站根文件夹中

我是个新来的人 我试图从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]

为什么会发生这样的事……没有人知道??这是真的,伙计:)你能为我解释一下为什么我的代码会导致文件夹出现问题吗???@Dinesh你没有检查文件是否存在,所以你也在重写文件夹名称。非常感谢你