一、web.config 主要应用在iis7/iis7.5的服务器上,编写规则的时候 注意 问号的使用,如 经常用到的 .*? 规则,到里面只能写成 .* 这块是需要注意的地方
二、httpd.ini 主要应用在iis以及iis6 的服务器上,跟.htaccess的规则比较接近,部分情况下需要区别 RewriteRule 的大小写,
跳转的部分需要用转义符转换url地址,如 /jourmy/go.php?act=xx&m=xx 需要写成/jourmy/go.php?act=xx&m=xx
三、.htaccess 主要应用在apache的服务器上,linux服务器时需要注意大小写 ,书写规则跟httpd.ini 比较接近
同一规则三种配置的书写规则:
web.config书写规则
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="rule1"> <match url="(/?html/.*)" ignoreCase="true" /> <action type="Rewrite" url="/gourl.php?url={R:1}" appendQueryString="true" /> </rule> <rule name="rule2"> <match url="(/?list/cate/.*)" ignoreCase="true" /> <action type="Rewrite" url="/gourl.php?url={R:1}" appendQueryString="true" /> </rule> <rule name="rule3"> <match url="(/?news/detail/.*)" ignoreCase="true" /> <action type="Rewrite" url="/gourl.php?url={R:1}" appendQueryString="true" /> </rule> <rule name="rule4"> <match url="(/?jourmy/cn/html/.*)" ignoreCase="true" /> <action type="Rewrite" url="/gourl.php?url={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
httpd.ini 书写规则
[ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 RewriteRule ^(/?html/.*?)$ /gourl.php?url=$1 [L] RewriteRule ^(/?list/cate/.*?)$ /gourl.php?url=$1 [L] RewriteRule ^(/?news/detail/.*?)$ /gourl.php?url=$1 [L]
.htaccess 书写规则
RewriteEngine on RewriteRule ^(/?html/.*?)$ /gourl.php?url=$1 [L] RewriteRule ^(/?list/cate/.*?)$ /gourl.php?url=$1 [L] RewriteRule ^(/?news/detail/.*?)$ /gourl.php?url=$1 [L] RewriteRule ^(/?jourmy/cn/html/.*?)$ /gourl.php?url=$1 [L]标签:gourl,RewriteRule,配置文件,静态,url,xx,三种,规则,php From: https://www.cnblogs.com/ytweb/p/17020025.html