迪恩素材教程资源图片下载站dz社区论坛discuz模板源码下载
2021-03-02 浏览:312
WordPress网址导航主题WebStackPro v2.0406下载
2021-03-01 浏览:206
WordPress主题modown6.2+erphpdown11.7源码下载
2021-02-26 浏览:482
thinkphp内核佐优家教平台家教网站源码(可封装成APP)下载
2021-03-05 浏览:409
使用Apache的.htaccess做301相信大家弄过,IIS的httpd.ini也不陌生,可是从IIS7以后都是web.config文件了,编写风格有点像xml,经过一通模仿,那服务器上测试,发现写起来也不难。
web.config文件通常都有下面这种开头
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <httpErrors errorMode="Custom"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="D:\wwwroot\xxxx\wwwroot\.shtml" responseMode="File" /> </httpErrors>
在下面接着写rewrite
<rewrite> <rules> <rule name="WWW Redirect" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^xxxxx.com$" /> </conditions> <action type="Redirect" url="http://www.xxxx.com/{R:0}" redirectType="Permanent" /> </rule> <rule name="Redirect" stopProcessing="true"> <match url="^products/xxxx/20171014/60.html" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Redirect" url="http://www.xxxxx.com/xxxx/item-60.html" /> </rule> <rule name="Redirect2" stopProcessing="true"> <match url="^products/xxxxxxx/" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Redirect" url="http://www.xxxxx.com/xxxx/" /> </rule>
WWW Redirect这一组是 将不带www跳转到带www上。
下面的Redirect、Redirect2都是一条一条单一的跳转规则,我们只需要按照这种写法无限延伸即可。
最后结尾处注意闭合rules、rewrite、system.webServer和configuration标签。
</rules> </rewrite> </system.webServer> </configuration>
完毕。经过测试 成功实现跳转。(可无限条<rules></rules>)
需要注意的是 规则不能写重复了,或者标点符号不要写错。