How to redirect readthedocs web pages to other website
Asked Answered
C

3

8

We started having our project's docs on readthedocs site (say http://abc.readthedocs.org). For various reasons we now moved to our own web servers with new domain (http://abc.io).

We want to bring down http://abc.readthedocs.org gracefully so that our project documentation is not broken all across the internet.

One way we are thinking is to have "redirects" from all pages with prefix (http://abc.readthedocs.org) to (http://abc.io).

But, I don't see any redirection options in readthedocs site that provides redirection to completely new domain. Readthedocs only allow redirection within different pages under same domain.

Any pointers on how I can proceed would be very helpful.

Chinaman answered 9/11, 2016 at 7:14 Comment(1)
Have you ever managed to find an answer for this?Collis
J
3

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

  • Prefix redirects (e.g. /dev/... -> /en/latest/...)
  • Page redirects (e.g. [/$lang/$version]/example.html -> [/$lang/$version]/examples/intro.html)
  • Exact redirects (e.g. /dev/install.html -> /en/latest/installing-your-site.html)

To migrate from an old Read the Docs project to somewhere else, the project is more involved:

  1. Add an Exact Redirect from /$rest to https://new.domain/
  2. Deactivate all versions of the old project, except latest (which can't be deactivated)
  3. Create a repository with a Sphinx project that only contains an index.rst with the following markup:
.. meta::
   :http-equiv=Refresh: 0; url='https://new.domain/en/latest/'
  1. Change the repository URL on https://readthedocs.org/dashboard/oldproject/edit/ to such repository
Jaws answered 11/11, 2021 at 12:34 Comment(0)
G
1

I added the following section to my 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>
Giron answered 6/6, 2017 at 10:50 Comment(0)
D
1

On the ReadTheDocs Admin page, the "Exact Redirect" form of redirection allows other domains in the "to URL" field. But it only seems to redirect one page per rule. That is, it requires an "Exact" match. I was hoping for some mod_rewrite magic using (.*) and $1. But that is not set up.

Another idea that works (but is clunky) is to create a temporary repository with a docs folder that uses markdown. The index.md file can consist of a refresh:

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

You can also add html with a direct link in case the refresh doesn't work.
The conf.py file can be:

from recommonmark.parser import CommonMarkParser

source_parsers = {'.md': CommonMarkParser}

source_suffix = ['.md']
master_doc = 'index'

Commit this repository to github (or other host) and change the project URL for your RTD project to this temporary repository. You can create tags for the temporary repos. to match those of your actual repository. Then make sure ReadTheDocs builds each version. If all goes well, the home pages of each version will redirect to wherever your refresh sends them.

It would be nice if the Redirects available on the Project Admin page would allow redirects of prefixes to other domains.

Dated answered 10/9, 2017 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.