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 mod_rewrite将文件转换为php和don';不显示文件类型_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess mod_rewrite将文件转换为php和don';不显示文件类型

.htaccess mod_rewrite将文件转换为php和don';不显示文件类型,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,给定一组URL,如下所示: http://site.com/filename.html http://site.com/filename.htm http://site.com/filename.php http://site.com/filename 使用.htaccess中的mod_rewrite模块,如何让它在 http://site.com/filename.php 并显示URL http://site.com/filename 这应该满足您的要求: RewriteRule ^([

给定一组URL,如下所示:

http://site.com/filename.html
http://site.com/filename.htm
http://site.com/filename.php
http://site.com/filename
使用.htaccess中的mod_rewrite模块,如何让它在

http://site.com/filename.php
并显示URL

http://site.com/filename
这应该满足您的要求:

RewriteRule ^([^\.]+)$ /$1.php [L]


编辑:在您的评论和问题中的更改之后-尝试以下操作:

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\. /$1 [R,L]
RewriteRule ^([^\.]+)$ $1.php [L]
试试这些规则:

# remove file name extension and redirect externally
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^?\ ]+\.(html?|php)
RewriteRule ^([^.]+)\.(html?|php)$ /$1 [L,R=301]

# rewrite to PHP file internally
RewriteRule ^[^.]+$ $0.php [L]
,给了我一个404。显示为。不满足约束条件。