2013-04-11 149 views
1

我已经创建了用于将非www重定向到www,/index.html到“/”,404到自定义页面的代码,我正在使用IIS服务器并将此代码放入网站。配置文件,看看,它的工作正常。但是我想知道对SEO有好处吗?或者它需要任何修改?重定向非www,index.html,404

感谢名单

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <rewrite> 
     <rules> 
     <rule name="CanonicalHostNameRule1" stopProcessing="true"> 
      <match url="index\.html(?:l)?" /> 
      <conditions> 
      <add input="{HTTP_HOST}" pattern="example\.com.au$" /> 
      </conditions> 
      <action type="Redirect" url="http://www.example.com.au/" /> 
     </rule> 
     <rule name="CanonicalHostNameRule2" stopProcessing="true"> 
      <match url="(.*)" /> 
      <conditions> 
      <add input="{HTTP_HOST}" pattern="^example\.com.au$" /> 
      </conditions> 
      <action type="Redirect" url="http://www.example.com.au/{R:1}" /> 
     </rule> 
     </rules> 
    </rewrite> 
    <httpErrors errorMode="Custom" existingResponse="Replace"> 
     <remove statusCode="404" /> 
     <error statusCode="404" responseMode="ExecuteURL" path="/404error.html" /> 
    </httpErrors> 
    </system.webServer> 
</configuration> 

回答

0

你的规则已经很好了。一般来说,让你的URL变成cannonical的想法是把所有的链接都指向一个单一的cannonical地址。在谷歌等公司的眼中,www.mydomain.commydomain.com是两个不同的URL。 mydomain.com/mydomain.com/imndex.html也是如此。我将添加到您的规则中的唯一一条是statusCode是302.这会告诉Google和客户端的浏览器,您希望他们从现在开始反悔目标网址。通过这种方式,Google可以将所有链接汇总到目标,并且客户端浏览器也不需要在每个请求中重新定向。