今天,无意中发现博客一个大的漏洞,不知道什么时候博客的301重定向设置失效了,这可对网站优化有很大的的影响,虽然我也不懂什么网站优化,同时访问博客喜欢不带www的域名,对用户体验也有很大影响。废话不多说,赶紧想办法解决问题,登陆博客后台,伪静态规则中的301重定向代码删除了,在网上搜索了代码插入伪静态规则中,一提交就出现冲突,网站打不开出现500错误提示。
在尝试了只单独设置伪静态和301重定向后,发觉这不是主机和程序不支持的问题,有可能是我把301重定向代码插入到伪静态规则中有误,不得已在Z-Blog论坛发表求助帖无回复后只有想主机提供商技术客服讨教了,好在客服很乐意的帮我修改了伪静态和301重定向规则,上传测试成功。由于伪静态在各种版本虚拟主机有各种伪静态和301重定向设置方法,这里就不在阐述了。小虎博客主机使用的是win2008虚拟主机,使用的伪静态规则是IIS7、7.5、8+Url Rewrite,代码如下(使用中请替换huhen.com域名):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.huhen.com$" />
</conditions>
<action type="Redirect" url="https://blog.huhen.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Imported Rule Default+Page" stopProcessing="true">
<match url="^default_([0-9]+)\.html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?page={R:1}" />
</rule>
<rule name="Imported Rule Category+Page" stopProcessing="true">
<match url="^category-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?cate={R:1}&page={R:2}" />
</rule>
<rule name="Imported Rule Category" stopProcessing="true">
<match url="^category-([0-9]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?cate={R:1}" />
</rule>
<rule name="Imported Rule Author+Page" stopProcessing="true">
<match url="^author-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?auth={R:1}&page={R:2}" />
</rule>
<rule name="Imported Rule Author" stopProcessing="true">
<match url="^author-([0-9]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?auth={R:1}" />
</rule>
<rule name="Imported Rule Tags+Page" stopProcessing="true">
<match url="^tags-([0-9]+)_([0-9]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?tags={R:1}&page={R:2}" />
</rule>
<rule name="Imported Rule Tags" stopProcessing="true">
<match url="^tags-([0-9]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?tags={R:1}" />
</rule>
<rule name="Imported Rule Date+Page" stopProcessing="true">
<match url="^date-([0-9\-]+)_([0-9]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?date={R:1}&page={R:2}" />
</rule>
<rule name="Imported Rule Date" stopProcessing="true">
<match url="^date-([0-9\-]+).html$" ignoreCase="false" />
<action type="Rewrite" url="catalog.asp?date={R:1}" />
</rule>
<rule name="Imported Rule Article" stopProcessing="true">
<match url="^post/(?!zb_)(.*).html$" ignoreCase="false" />
<action type="Rewrite" url="view.asp?id={R:1}" />
</rule>
<rule name="Imported Rule Page" stopProcessing="true">
<match url="^(?!zb_)(.*).html$" ignoreCase="false" />
<action type="Rewrite" url="view.asp?id={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
一般人很容易解决这个问题,对于菜鸟的我来说,是不懂而已。