【问题标题】:How to redirect readthedocs web pages to other website如何将 readthedocs 网页重定向到其他网站
【发布时间】:2017-03-22 22:52:55
【问题描述】:

我们开始在 readthedocs 网站上发布我们项目的文档(比如http://abc.readthedocs.org)。由于各种原因,我们现在转移到我们自己的具有新域 (http://abc.io) 的 Web 服务器。

我们想优雅地关闭http://abc.readthedocs.org,这样我们的项目文档就不会在整个互联网上被破坏。

我们正在考虑的一种方法是从所有带有前缀 (http://abc.readthedocs.org) 的页面“重定向”到 (http://abc.io)。

但是,我在 readthedocs 站点中没有看到任何提供重定向到全新域的重定向选项。 Readthedocs 只允许在同一域下的不同页面内进行重定向。

任何关于我如何进行的指示都会非常有帮助。

【问题讨论】:

  • 你有没有找到答案?

标签: read-the-docs


【解决方案1】:

Read the Docs offers several kinds of user-defined redirects:

  • 前缀重定向(例如/dev/... -> /en/latest/...
  • 页面重定向(例如[/$lang/$version]/example.html -> [/$lang/$version]/examples/intro.html
  • 精确重定向(例如/dev/install.html -> /en/latest/installing-your-site.html

要从旧的 Read the Docs 项目迁移到其他地方,该项目涉及更多:

  1. 添加一个精确/$rest重定向到https://new.domain/
  2. 停用旧项目的所有版本,latest 除外(无法停用)
  3. 使用仅包含 index.rst 和以下标记的 Sphinx 项目创建存储库:
.. meta::
   :http-equiv=Refresh: 0; url='https://new.domain/en/latest/'
  1. https://readthedocs.org/dashboard/oldproject/edit/ 上的存储库 URL 更改为此类存储库

【讨论】:

    【解决方案2】:

    在 ReadTheDocs 管理页面上,“精确重定向”形式的重定向允许“到 URL”字段中的其他域。但它似乎只为每条规则重定向一页。也就是说,它需要“精确”匹配。我希望 some mod_rewrite 使用 (.*)$1 的魔法。但这并没有设置。

    另一个可行的想法(但很笨拙)是创建一个临时存储库,其中包含一个使用 markdown 的 docs 文件夹。 index.md 文件可以包含一个刷新:

    <meta http-equiv="refresh" content="0; URL=https://new.location">`
    

    您还可以添加带有直接链接的 html,以防刷新不起作用。
    conf.py 文件可以是:

    from recommonmark.parser import CommonMarkParser
    
    source_parsers = {'.md': CommonMarkParser}
    
    source_suffix = ['.md']
    master_doc = 'index'
    

    将此存储库提交到 github(或其他主机)并将您的 RTD 项目的项目 URL 更改为此临时存储库。您可以为临时存储库创建标签。以匹配您的实际存储库。然后确保 ReadTheDocs 构建每个版本。如果一切顺利,每个版本的主页都会重定向到刷新发送它们的位置。

    如果项目管理页面上可用的重定向允许将前缀重定向到其他域,那就太好了。

    【讨论】:

      【解决方案3】:

      我将以下部分添加到我的index.rst

      .. raw:: html
      
          <script type="text/javascript">
          if (String(window.location).indexOf("readthedocs") !== -1) {
              window.alert('The documentation has moved. I will redirect you to the new location.');
              window.location.replace('http://cosmo-docs.phys.ethz.ch/cosmoHammer');
          }
          </script>
      

      【讨论】:

        猜你喜欢
        • 2017-04-30
        • 2018-08-05
        • 1970-01-01
        • 2015-07-31
        • 2023-03-12
        • 1970-01-01
        • 1970-01-01
        • 2019-10-20
        • 2016-06-21
        相关资源
        最近更新 更多