tp5 iis服务器伪静态配置
百度了iis服务器伪静态配置,说是配置web.config文件,一直没弄成功,参考其它网站发现是可以用httpd.ini实现的
httpd.ini 是什么
httpd.ini是IIS的配置文件,支持伪静态配置。并放置在windows主机上,当我们用习惯了apache下的.htaccess的时候,很难想象windows主机上怎么实现它的强大功能。实际上windows主机服务器上的虚拟主机可以用httpd.ini文件来充当.htaccess文件在Linux主机空间的作用,不过要令你失望的是,httpd.ini的功能完全没有.htaccess那么强大,规则上没有那么丰富,细节上也有很大的不同。要在你的空间使用httpd.ini首先得确定你的空间是否支持httpd.ini伪静态功能,可以询问服务商,没有需要进行安装。
参照这段代码
[ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # Protect httpd.ini and httpd.parse.errors files # from accessing through HTTP RewriteRule ^/httpd(?:\.ini|\.parse\.errors).* [F,I,O] RewriteRule ^(.*)/html/([^./]*)[/|]$ $1/index.php\?f=$2 RewriteRule ^(.*)/html/([^./]*)/([0-9]+).html $1/index.php\?f=$2&c=$3 RewriteRule ^(.*)/html/([^./]*)/(view)_([0-9]+).html $1/index.php\?f=$2&a=$3&r=$4 RewriteRule ^(.*)/html/([^./]*)/(view)_([0-9]+)_([0-9]+).html $1/index.php\?f=$2&a=$3&c=$4&r=$5 RewriteRule ^(.*)/html/([^./]*)/(send)_([0-9]+).html $1/index.php\?f=$2&a=$3&r=$4
RewriteRule 其实就地址的正则表达式替换的写法
分析这条规则:RewriteRule ^(.*)/html/([^./]*)[/|]$ $1/index.php\?f=$2
根据左边正则 匹配到的字符串
^(.*)/html/([^./]*)[/|]$
右边重新组装,$1、2、3...就是匹配到的值
$1/index.php\?f=$2
tp5想隐藏掉index.php入口文件
我最终根据我网站得到这个配置解决问题
[ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # 给所有.html结尾的路径隐藏index.php RewriteRule ^(.*)html /index.php?/$1html # 给所有a-z或0-9或/线的 路径隐藏index.php RewriteRule ^([a-z\A-z0-9/]*) /index.php?/$1