使用htaccess从文件中删除.php
我想从每个url下载stream.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] ###
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]
查看此问答: