.htaccess mod_rewrite将文件转换为php和don';不显示文件类型
给定一组URL,如下所示:.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 ^([
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。显示为。不满足约束条件。