Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
使用htaccess从文件中删除.php_Php_.htaccess - Fatal编程技术网

使用htaccess从文件中删除.php

使用htaccess从文件中删除.php,php,.htaccess,Php,.htaccess,我想从每个url下载stream.php 像localhost/index.php-->localhost/index 但是我也希望localhost/index/也能工作 这是我正在使用的当前代码 #for hiding.php extension RewriteEngine On RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule ^(.*)/?$ $1\.php [NC] ###

我想从每个url下载stream.php 像
localhost/index.php
-->
localhost/index
但是我也希望
localhost/index/
也能工作

这是我正在使用的当前代码

#for hiding.php extension
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)/?$ $1\.php [NC]
############################-------- END ---------########################
有人能提出修改建议吗?

试试:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ /$1.php [L]
查看此问答: