三種偽靜態(tài)配置文件的轉(zhuǎn)換
2017-03-24 01:01:45
16884
三種偽靜態(tài)配置文件的轉(zhuǎn)換
一、web.config 主要應(yīng)用在iis7/iis7.5的服務(wù)器上,編寫(xiě)規(guī)則的時(shí)候 注意 問(wèn)號(hào)的使用,如 經(jīng)常用到的 .*? 規(guī)則,到里面只能寫(xiě)成 .* 這塊是需要注意的地方
二、httpd.ini 主要應(yīng)用在iis以及iis6 的服務(wù)器上,跟.htaccess的規(guī)則比較接近,部分情況下需要區(qū)別 RewriteRule 的大小寫(xiě),
跳轉(zhuǎn)的部分需要用轉(zhuǎn)義符轉(zhuǎn)換url地址,如 /jourmy/go.php?act=xx&m=xx 需要寫(xiě)成/jourmy/go.php?act=xx&m=xx
三、.htaccess 主要應(yīng)用在apache的服務(wù)器上,linux服務(wù)器時(shí)需要注意大小寫(xiě) ,書(shū)寫(xiě)規(guī)則跟httpd.ini 比較接近
同一規(guī)則三種配置的書(shū)寫(xiě)規(guī)則:
web.config書(shū)寫(xiě)規(guī)則
<?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 書(shū)寫(xiě)規(guī)則
[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 書(shū)寫(xiě)規(guī)則
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]
會(huì)員登錄
賬號(hào)登錄還沒(méi)有賬號(hào)?立即注冊(cè)