php - htaccess正在搞乱. php 扩展?

  显示原文与译文双语对照的内容
58 0

好的,所以我有这个mod_rewrite规则,如果在发送请求时没有提供. html 扩展,那么它将在内部附加:

Options +FollowSymLinks
RewriteEngine on
#
## Internally rewrite extensionless file requests to. html files ##
#
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI}!(.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_FILENAME}!-d
# and if it does not exist as a file
RewriteCond %{REQUEST_FILENAME}!-f
# then add. html to get the actual filename
RewriteRule (.*)/$1.html [L]
#
#
## Externally redirect clients directly requesting. html page URIs to extensionless URIs
#
# If client request header contains html file extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}/([^.]+.)+html HTTP 
# externally redirect to extensionless URI
RewriteRule ^(.+).html$ http://www.example.com/$1 [R=301,L]

如果想在这个文件的第一部分中修改. html 到. php,那么当有人请求一个. php 文件时,它就会被扩展到这个. php 页面,它仍然会进入这个页面。结果是这样的。为什么不?

我的证据如下:http://appstorecrazy.com/OHNOEZ/NOTEST

时间:原作者:0个回答

138 0

尝试以下处理php的规则:

## Internally rewrite extensionless file requests to. php files ##
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI}!(.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_FILENAME}!-d
# and if it does not exist as a file
RewriteCond %{REQUEST_FILENAME}!-f
# then add. html to get the actual filename
RewriteRule (.*)/$1.php [L]
## Externally redirect clients directly requesting. php page URIs to extensionless URIs
#
# If client request header contains html file extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}/([^.]+).php
# externally redirect to extensionless URI
RewriteRule ^(.+).php$/$1 [R=301,L]
原作者:
...