【问题标题】:301 redirects with Joomla on IIS在 IIS 上使用 Joomla 进行 301 重定向
【发布时间】:2009-09-08 02:08:26
【问题描述】:

我在 IIS 上运行 Joomla。我有大约十几个类别(金融通讯出版商),我用它们来组织大约 40 篇文章(金融通讯)。我正在使用 joomla 内置的 SEO,所以 URL 看起来像这样:

http://www.global-autotrading.com/autotraded-newsletters/13-angel-publishing/43-options-trading-pit.html

类别和文章前面的数字很烦人,我不太喜欢 Section Layout 菜单项提供的导航。此外,一些财经通讯不在出版商的保护下运作,所以我想要一个更灵活的组织。

我尝试简单地构建一个菜单层次结构(在自动交易的时事通讯菜单下),其中有一些时事通讯直接位于父菜单项下,一些出版商将时事通讯作为菜单项在其下方。但是,这导致一些链接中断;点击一个链接会把我带到错误的文章,什么不是。因此,使用手动编码的菜单结构似乎与使用内容的另一个“并行”部分布局视图不兼容。

因此,我决定放弃使用类别来组织内容的想法。我将为每个“发布者”类别创建一篇文章。我将在该出版商的文章中手动添加指向每个出版商时事通讯的链接。我还将像上面描述的那样创建一个并行菜单结构。

无论如何,这是很多背景信息,希望我能得到一些确认,证明我所做的事情没有根本性的缺陷。

问题是有外部网站直接链接到上面的某些 URL。我不希望这些链接中断(我相信经典的 SEO 问题)。我认为解决方案是使用 301 重定向到(例如)重定向:

http://www.global-autotrading.com/autotraded-newsletters/13-angel-publishing/43-options-trading-pit.html

http://www.global-autotrading.com/autotraded-newsletters/angel-publishing/options-trading-pit.html

或来自

http://www.global-autotrading.com/autotraded-newsletters/4-10-percent-per-month/12-10-percent-per-month.html

http://www.global-autotrading.com/autotraded-newsletters/10-percent-per-month.html

在 IIS 中创建 301 重定向有各种指南(例如:http://www.webconfs.com/how-to-redirect-a-webpage.php),但我想知道这些指南是否与 Joomla 兼容,尤其是与启用了 SEO 功能的 Joomla 兼容。

另外,如果我做错了什么,请告诉我 :)

谢谢!

【问题讨论】:

    标签: iis redirect joomla http-status-code-301 joomla-sef-urls


    【解决方案1】:

    这是一个有效的 web.config 文件的重写部分。最棘手的部分是弄清楚重定向规则需要先于 web.config 中的 SEO 规则

    <rewrite>
      <rewriteMaps>
        <rewriteMap name="StaticRedirects">
          <add key="/old-url-1.html" value="new-url-1.html" />
          <add key="/old-url-2.html" value="new-url-2.html" />
        </rewriteMap>
      </rewriteMaps>
      <rules>
        <rule name="Security Rule" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAny">
            <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" ignoreCase="false" />
            <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" ignoreCase="false" />
            <add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\>|%3E)" />
            <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
            <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
          </conditions>
          <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
        </rule>
        <rule name="Redirect Rule" stopProcessing="false">
          <match url=".*" />
          <conditions>
            <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}" appendQueryString="False" redirectType="Permanent" />
        </rule>
        <rule name="SEO Rule">
          <match url="(.*)" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" />
            <add input="{URL}" negate="true" pattern="^/index.php" ignoreCase="false" />
            <add input="{URL}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
    

    【讨论】:

      【解决方案2】:

      与此类似的代码最近包含在从 1.6.2 版开始的默认 Joomla 安装中。

      在任何内部重写之前列出所有外部重定向很重要,否则重写的指针将在不经意间作为新 URL 暴露在网络上。

      【讨论】:

        猜你喜欢
        • 2012-12-14
        • 2020-03-28
        • 1970-01-01
        • 2010-12-09
        • 1970-01-01
        • 2019-05-30
        • 2014-08-30
        • 2017-04-15
        • 2018-03-09
        相关资源
        最近更新 更多