简体   繁体   English

301使用IIS上的Joomla重定向

[英]301 redirects with Joomla on IIS

I'm running Joomla on IIS. 我在IIS上运行Joomla。 I've got about a dozen categories (financial newsletter publishers) that I'm using to organize about 40 articles (financial newsletters). 我有大约十二个类别(财经新闻出版商),我正在用来组织约40篇文章(财经新闻通讯)。 I'm using the joomla built-in SEO so the URL's look like this: 我正在使用joomla内置SEO,因此URL如下所示:

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

The numbers in front of the categories and articles are annoying, and I'm not too fond of the navigation provided by a Section Layout menu item. 类别和文章前面的数字很烦人,我不太喜欢“版面布局”菜单项提供的导航。 Also, some financial newsletters don't operate under the umbrella of a publisher so I want a more flexible organization. 另外,某些财务新闻通讯不会在发行商的保护下运作,所以我想要一个更灵活的组织。

I've tried simply constructing a menu hierarchy (under the autotraded newsletters menu) that has some newsletters directly under the parent menu item, and some publishers with their newsletters as menu items underneath them. 我已经尝试过简单地构建菜单层次结构(在自动交易的新闻通讯菜单下),在父菜单项的正下方有一些新闻通讯,而在其下方的菜单项中有一些发布商将其新闻通讯作为菜单项。 However, that was causing some links to break; 但是,这导致某些链接断开。 clicking on a link would take me to the wrong article, and what not. 点击链接会将我带到错误的文章,而不是错误的文章。 Thus, it seems like using a hand-coded menu structure is not compatible with using another, "parallel" section-layout view of the content. 因此,似乎使用手动编码的菜单结构与使用内容的另一个“平行”部分布局视图不兼容。

Thus, I've decided to get rid of the idea of using categories to organize that content. 因此,我决定摆脱使用类别组织内容的想法。 I'm going to create an article for each "publisher" category. 我将为每个“发布者”类别创建一篇文章。 I'll manually add links to each publisher's newsletters in that publisher's article. 我将在该发布者的文章中手动添加指向每个发布者的新闻通讯的链接。 I'll also create a parallel menu structure like I was describing above. 我还将创建一个并行菜单结构,就像我上面描述的那样。

Anyway, that's a lot of background info, with the hope that I'll get some confirmation that I'm not doing something fundamentally flawed. 无论如何,这是很多背景信息,希望我能得到一些确认,我没有做有根本缺陷的事情。

The problem is that there are external sites linking directly to some URLs like above. 问题是,有外部站点直接链接到上述某些URL。 I don't want these links to break (classic SEO problem, I believe). 我不希望这些链接断开(我相信经典的SEO问题)。 I think the solution is to use 301 redirects to (for example) redirect from: 我认为解决方案是使用301重定向来(例如)从以下位置重定向:

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

to

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

or from 或来自

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/4-10-percent-per-month/12-10-percent-per-month.html

to

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

There are various guidelines around for creating 301 redirects in IIS (ex: http://www.webconfs.com/how-to-redirect-a-webpage.php ), but I was wondering if these are compatible with Joomla, particularly with Joomla with the SEO features turned on. 在IIS中创建301重定向的方法有很多(例如: http : //www.webconfs.com/how-to-redirect-a-webpage.php ),但是我想知道它们是否与Joomla兼容,尤其是与Joomla兼容已启用SEO功能的Joomla。

Also, if it seems like I'm doing something fundamentally wrong, please let me know :) 另外,如果我根本上做错了,请告诉我:)

Thanks! 谢谢!

Here is the rewrite section of a web.config file that works. 这是有效的web.config文件的重写部分。 The trickiest part was to figure out that the redirect rules need to preceed the SEO rules in the 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>

Code similar to this was recently included in the default Joomla install starting at version 1.6.2. 从版本1.6.2开始,默认的Joomla安装中最近包含了与此类似的代码。

It is important that all external redirects are listed before any internal rewrites, otherwise the rewritten pointer will be inadvertently exposed back on to the web as a new URL. 重要的是,在进行任何内部重写之前,所有外部重定向都必须列出,否则重写后的指针将作为新的URL不经意地重新显示在Web上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM