【问题标题】:Redirecting non www, index.html, 404重定向非 www、index.html、404
【发布时间】:2013-04-03 05:01:18
【问题描述】:

我已经创建了将非 www 重定向到 www、/index.html 到“/”、404 到自定义页面的代码,我正在使用 IIS 服务器并将此代码放在 web.config 文件中,看看它的工作原理美好的。但我想知道它对 SEO 有好处吗?还是需要修改?

感谢

<?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>

【问题讨论】:

    标签: asp.net iis redirect http-status-code-404 no-www


    【解决方案1】:

    您的规则看起来不错。一般来说,使您的 URL 成为规范的想法是将所有链接汁导向单个规范地址。在 Google 等人的眼中,www.mydomain.commydomain.com 是两个不同的 URL。 mydomain.com/mydomain.com/imndex.html 也是如此。我要添加到您的规则中的唯一内容是 302 的 statusCode。这将告诉 Google 和客户端的浏览器您希望他们从现在开始引用目标 URL。通过这种方式,Google 会将所有链接果汁汇总到目标,并且客户端浏览器也不需要在每次请求时重新重定向。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-02
      • 1970-01-01
      • 2019-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多