IIS7 通过伪静态文件web.config实现根域名301跳转
作者:shao65308 日期:2013-06-17
这是我一个网站的web.config文件的全部内容,红色部分是用来实现根域名301跳转的
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="taohuabao.com" />
</conditions>
<action type="Redirect" url="http://www.taohuabao.com/{R:0}" />
</rule>
<rule name="list cpage">
<match url="^list_([^/_]+)_([\d]+)[/]?$" ignoreCase="true" />
<action type="Rewrite" url="guang.php?cl={R:1}&cpage={R:2}" appendQueryString="true" />
</rule>
<rule name="list">
<match url="^list_([^/_]+)[/]?$" ignoreCase="true" />
<action type="Rewrite" url="guang.php?cl={R:1}" appendQueryString="true" />
</rule>
<rule name="cont">
<match url="cont_([0-9]+)_([0-9]+)_([0-9]+)[/]?$" ignoreCase="true" />
<action type="Rewrite" url="count.php?uid={R:1}&sid={R:2}&aid={R:3}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
附上另一个通过ISAPI_Rewrite3组件实现伪静态的跳转代码,见红色部分
RewriteCond %{HTTP_HOST} ^taowhy\.com [NC]
RewriteRule ^(.*)$ http:\/\/www\.taowhy\.com$1 [L,R=301]
RewriteRule ^(.*)article\/(.+)\.html$ $1/article\.php\?name=$2
RewriteRule ^(.*)product\/(.+)\.html$ $1/product\.php\?name=$2
RewriteRule ^(.*)category\/([^/_]+)[/]?$ $1/category\.php\?name=$2
RewriteRule ^(.*)category\/([^/]+)_([0-9]+)[/]?$ $1/category\.php\?name=$3&p=$3
RewriteRule ^(.*)catalog\/([^/]+)[/]?$ $1/catalog\.php\?type=$2
程序代码
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="taohuabao.com" />
</conditions>
<action type="Redirect" url="http://www.taohuabao.com/{R:0}" />
</rule>
<rule name="list cpage">
<match url="^list_([^/_]+)_([\d]+)[/]?$" ignoreCase="true" />
<action type="Rewrite" url="guang.php?cl={R:1}&cpage={R:2}" appendQueryString="true" />
</rule>
<rule name="list">
<match url="^list_([^/_]+)[/]?$" ignoreCase="true" />
<action type="Rewrite" url="guang.php?cl={R:1}" appendQueryString="true" />
</rule>
<rule name="cont">
<match url="cont_([0-9]+)_([0-9]+)_([0-9]+)[/]?$" ignoreCase="true" />
<action type="Rewrite" url="count.php?uid={R:1}&sid={R:2}&aid={R:3}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
附上另一个通过ISAPI_Rewrite3组件实现伪静态的跳转代码,见红色部分
程序代码
RewriteCond %{HTTP_HOST} ^taowhy\.com [NC]
RewriteRule ^(.*)$ http:\/\/www\.taowhy\.com$1 [L,R=301]
RewriteRule ^(.*)article\/(.+)\.html$ $1/article\.php\?name=$2
RewriteRule ^(.*)product\/(.+)\.html$ $1/product\.php\?name=$2
RewriteRule ^(.*)category\/([^/_]+)[/]?$ $1/category\.php\?name=$2
RewriteRule ^(.*)category\/([^/]+)_([0-9]+)[/]?$ $1/category\.php\?name=$3&p=$3
RewriteRule ^(.*)catalog\/([^/]+)[/]?$ $1/catalog\.php\?type=$2
评论: 0 | 引用: 0 | 查看次数: 3546
发表评论
你没有权限发表评论!