-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix Exact Redirect to work properly when using $rest keyword #4501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
f1c97a8
f434859
9be5d08
4f85a21
7888783
666b20f
829af19
f6fed2d
54cb8d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
User-defined Redirects | ||
====================== | ||
|
||
You can set up redirects for a project in your project dashboard's Redirects page. | ||
You can set up redirects for a project in your project dashboard's Redirects page. | ||
|
||
Quick Summary | ||
------------- | ||
|
||
* Log into your Readthedocs.com Admin account. | ||
* Log into your readthedocs.org account. | ||
* From your dashboard, select the project on which you wish to add redirects. | ||
* From the project's top navigation bar, select the Admin tab. | ||
* From the left navigation menu, select Redirects. | ||
* From the left navigation menu, select Redirects. | ||
* In the form box "Redirect Type" select the type of redirect you want. See below for detail. | ||
* Depending on the redirect type you select, enter FROM and/or TO URL as needed. | ||
* When finished, click the SUBMIT Button. | ||
|
@@ -18,6 +18,7 @@ Your redirects will be effective immediately. | |
|
||
Redirect Types | ||
-------------- | ||
|
||
Prefix Redirects | ||
~~~~~~~~~~~~~~~~ | ||
|
||
|
@@ -39,11 +40,19 @@ The example configuration would be:: | |
|
||
Your users query would now redirect in the following manner:: | ||
|
||
docs.example.com/dev/install.html -> | ||
docs.example.com/en/latest/install.html | ||
docs.example.com/dev/install.html -> | ||
docs.example.com/en/latest/install.html | ||
|
||
Where ``en`` and ``latest`` are the default language and version values for your project. | ||
|
||
|
||
.. note:: | ||
|
||
In other words, a *Prefix Redirect* removes a prefix from the original URL. | ||
This prefix is removed from the rest of the URL's ``path`` after ``/$lang/$version``. | ||
For example, if the URL is ``/es/1.0/guides/tutorial/install.html`` the "From URL's prefix" will be removed from ``/guides/tutorial/install.html`` part. | ||
|
||
|
||
Page Redirects | ||
~~~~~~~~~~~~~~ | ||
|
||
|
@@ -59,9 +68,14 @@ You would set the following configuration:: | |
From URL: /example.html | ||
To URL: /examples/intro.html | ||
|
||
Note that the ``/`` at the start doesn't count the ``/en/latest``, | ||
Note that the ``/`` at the start doesn't count the ``/en/latest``, | ||
but just the user-controlled section of the URL. | ||
|
||
.. tip:: | ||
|
||
*Page Redirects* can redirect URLs **outside** Read the Docs platform. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe is worth mentioning that is enough to put an absolute url to archive this? |
||
|
||
|
||
Exact Redirects | ||
~~~~~~~~~~~~~~~ | ||
|
||
|
@@ -81,20 +95,41 @@ The example configuration would be:: | |
|
||
Your users query would now redirect in the following manner:: | ||
|
||
docs.example.com/dev/install.html -> | ||
docs.example.com/en/latest/installing-your-site.html | ||
docs.example.com/dev/install.html -> | ||
docs.example.com/en/latest/installing-your-site.html | ||
|
||
Note that you should insert the desired language for "en" and version for "latest" to | ||
achieve the desired redirect. | ||
|
||
*Exact Redirects* could be also useful to redirect a whole sub-path to a different one by using a special ``$rest`` keyword in the "From URL". | ||
Let's say that you want to redirect your readers of your version ``2.0`` of your documentation under ``/en/2.0/`` because it's deprecated, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This useful when renaming dirs too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When renaming dirs the |
||
to the newest ``3.0`` version of it at ``/en/3.0/``. | ||
|
||
This example would be:: | ||
|
||
Type: Exact Redirect | ||
From URL: /en/2.0/$rest | ||
To URL: /en/3.0/ | ||
|
||
The readers of your documentation will now be redirected as:: | ||
|
||
docs.example.com/en/2.0/dev/install.html -> | ||
docs.example.com/en/3.0/dev/install.html | ||
|
||
|
||
.. tip:: | ||
|
||
*Exact Redirects* can redirect URLs **outside** Read the Docs platform. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same note |
||
|
||
|
||
Sphinx Redirects | ||
~~~~~~~~~~~~~~~~ | ||
|
||
We also support redirects for changing the type of documentation Sphinx is building. | ||
If you switch between *HTMLDir* and *HTML*, your URL's will change. | ||
A page at ``/en/latest/install.html`` will be served at ``/en/latest/install/``, | ||
or vice versa. | ||
The built in redirects for this will handle redirecting users appropriately. | ||
The built in redirects for this will handle redirecting users appropriately. | ||
|
||
Implementation | ||
-------------- | ||
|
@@ -105,4 +140,3 @@ This means that redirects will only happen in the case of a *404 File Not Found* | |
|
||
In the future we might implement redirect logic in Javascript, | ||
but this first version is only implemented in the 404 handlers. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this note is necessary, I found it a little confusing, the above example makes more sense for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to have a simple way to explain what
Prefix Redirects
does because it seems that explaining it by example with a "custom domain" is not enough and confuses people that don't use a custom domain.So, I'd like to have something very simple explained in one line. Maybe my one-line explanation is not the best and someone can help me here. But I'd like to keep a note like this.