-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix Exact Redirect to work properly when using $rest keyword #4501
Conversation
|
||
.. note:: | ||
|
||
In other words, a *Prefix Redirect* removes a prefix from the original URL. |
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.
docs/user-defined-redirects.rst
Outdated
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 comment
The 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 comment
The 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?
|
||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
When renaming dirs the $rest
argument shouldn't be used. Instead, you should just use /old-dir/
to /new-dir/
. This way, it will do this under all of the languages and versions.
docs/user-defined-redirects.rst
Outdated
|
||
.. tip:: | ||
|
||
*Exact Redirects* can redirect URLs **outside** Read the Docs platform. |
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.
Same note
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.
Looks good. I remember that redirects also have some weird behavior with a leading /
, which might be worth investigating here also.
I particularly like the examples. It would probably be useful for us to provide more examples like this, particularly around cases that are common.
Good point! I just added a test for this to check how it behaves. I'm not sure what's the expected behavior here, but what it does sounds useless to me. Example:
Hitting What would be good use case for this? Should we validate the presence of the leading |
Validate that leading/trailing slash is used in PREFIX redirects when using $rest keyword. Add other minor test cases for other types of redirects.
I added some test cases and some validation at Form level to avoid people submitting malformed URL (missing leading/trailing slashes). I suppose this is ready to merge once the tests pass. A large project related to these changes is to have real redirects, not only on 404: #4550 |
I believe there are other redirects with similar problems. For example:
This will return |
Just realized that we do support redirect to external URLs, so we need to support URLs starting with I think this is deviating from the original purpose of the PR: fix the exact redirect with the usage of |
Sounds good. 👍 |
This reverts commit f6fed2d.
@humitos When will this fix go live? I'm unable to get it working just yet....Thank you so much for your work on this! 🎊 |
@wohali Hi! We are planning to deploy this tomorrow. |
This is already deployed and should be working. |
In #3965 we added the ability to use the
full_path
but it was added only to the first case and it wasn't considered in the case when$rest
keyword was used.With these changes we can "deprecate a whole sub-path" by writing a Exact Redirect like this:
and all links pointing to the
obsolete-version
at any sub-path will be redirected to the newest docs.Closes #4029
Closes #2444
Closes #3794