首页 学习教程网站建设正文

IIS7 IIS7.5 伪静态 web.config 配置方法不带WWW的301跳转到带WWW

元之本 网站建设 2019-11-30 20:54:02 1877 0
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(w1.baidu.com|w2.taobao.com|xyw0001.my3w.com)$" />
</conditions>
<action type="Rewrite" url="down2/{R:0}" />
</rule>
IIS7 做伪静态比较的简单方便  
1.程序方面
只需要设置web.config 就可以了。
 
2.服务器需要安装:URL Rewrite
下载地址:http://www.iis.net/download/URLRewrite
Godaddy 的主机已经安装这个插件。
本地在测试的时候 请查看自己是否安装这个插件。
 
注意要点
1.参数用“()” 括起来 ,使用 {R:1}来获得参数
2.多个参数中间用 &amp; 分割
3.name切记不能写一样 
 
<?xml version="1.0"?>
<configuration>
<system.webServer>
        <rewrite>
            <rules>
 
 
<!--把二级域名(或指定的域名) 转到目录下-->
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(w1.baidu.com|w2.taobao.com|xyw0001.my3w.com)$" />
</conditions>
<action type="Rewrite" url="down2/{R:0}" />
</rule>
 
 
                <!--301重定向把不带3W的域名 定向到带3W-->
                <rule name="Redirect" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^xamjj.com$" />
                    </conditions>
                    <action type="Redirect" url="http://www.xamjj.com/{R:0}" redirectType="Permanent" />
                </rule>
                <!--首页-->
                <rule name="rD">
                    <match url="^$" />
                    <action type="Rewrite" url="Default.aspx" />
                </rule>
                <!--产品列表-->
                <rule name="rP">
                    <match url="^product/$" />
                    <action type="Rewrite" url="ProductList.aspx" />
                </rule>
                <!--产品列表第几页-->
                <rule name="rPL">
                    <match url="^product/list-([0-9]*).html$" />
                    <action type="Rewrite" url="ProductList.aspx?page={R:1}" />
                </rule>                
                <!--产品类别列表-->
                <rule name="rPT">
                    <match url="^product/([A-Za-z0-9-]*)/$" />
                    <action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}" />
                </rule>
                <!--产品类别列表第几页-->
                <rule name="rPTL2">
                    <match url="^product/([A-Za-z0-9-]*)/list-([0-9]*).html$" />
                    <action type="Rewrite" url="ProductList.aspx?typeUrl={R:1}&amp;page={R:2}" />
                </rule>
                <!--产品详细-->
                <rule name="rPd">
                    <match url="^product/([A-Za-z0-9-]*)/([A-Za-z0-9-]+).html$" />
                    <action type="Rewrite" url="ProductDetail.aspx?typeUrl={R:1}&amp;url={R:2}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


打赏 支付宝打赏 微信打赏

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

本文链接:http://www.yuyubebe.cn/2019/11/591/

发表评论

评论列表(0人评论 , 1877人围观)
☹还没有评论,来说两句吧...
«    2023年4月    »
12
3456789
10111213141516
17181920212223
24252627282930
宝塔服务器面板,一键全能部署及管理,送你3188元礼包,点我领取