Skip to content
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

Redirect rules to wire up the 9.0 guide #77

Merged
merged 4 commits into from
May 8, 2022

Conversation

janhoy
Copy link
Contributor

@janhoy janhoy commented May 5, 2022

The purpose of this is to

  • Add a rewrite rule for /guide/solr/X_Y to the __root area
  • Add an "alias" so that /guide/9_0 gets redirected (not rewritten) to /guide/solr/9_0
  • Adapt the wildcard rule /guide/[a-z].* which would earlier rewrite /guide/solr/xxx to /guide/8_11/solr/xxx, make exception for solr. After 9.0 release this rule will likely instead be /guide/solr/foo pointing to /guide/solr/latest/foo??
  • Add preliminary htaccess.ref-guide-antora to test the /guide/solr/latest -> /guide/solr/9_0 redirect

This can be committed now, before the release, as there will still be nowhere on our page linking to it. This way we can test the entire new guide on the real site before announcing it.

@janhoy janhoy requested a review from HoustonPutman May 5, 2022 14:50
@janhoy janhoy requested review from hossman and uschindler May 6, 2022 00:14
# Ref-guides up to 8.x
RewriteRule ^guide/(6|7|8)_\d+.*$ __root/docs.solr.apache.org/$0 [PT]
# Redirect v9 and higher guides on format /guide/9_0/foo to /guide/solr/9_0/foo
RedirectMatch Permanent ^/guide/((9|1\d)_\d.*$) /guide/solr/$1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be a bit careful here as the order of instructions in this file does not guarantee they are executed in that order (I think all rewrites are executed before all redirects). But it looks correct. Maybe we should test this a bit on the staging server.

I would only use RewriteRules and don't mix them here with RedirectMatch. You can use RewriteRules to redirect by adding "[R]" as option at end. If you only have Rewrite rules they are executed in order and you can mark a "matching one" as "last" with "[L]". This allows to do not apply any further rules after the first matched.

For redirects the rule would end in "[R,L]" (redirect and last).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, removing the redirectmatch, and dealying that particular redirect for now.
Going to merge to staging to test the rules (although the guide will not be visible in staging)

@janhoy janhoy merged commit 8071d21 into apache:main May 8, 2022
@janhoy janhoy deleted the Htaccess-refguide-9_0 branch May 8, 2022 21:10
@HoustonPutman
Copy link
Contributor

Trying this out on staging, this:

https://solr.staged.apache.org/guide/solr

gets re-routed to:

https://solr.staged.apache.org/guide/8_11/solr/

which is not what we want.

https://solr.staged.apache.org/guide/solr/ works fine, so we just need to make an explicit exception for the https://solr.staged.apache.org/guide/solr url, since it is assuming that solr is the documentation page.

@janhoy
Copy link
Contributor Author

janhoy commented May 9, 2022

Yep, but I think we can simplify this once 9.0 is released, since we don't need this anymore

RedirectMatch temp ^/guide/(?!index.html)(?!solr/)(?!search-index.js)([a-z].*) /guide/{{ SOLR_LATEST_RELEASE.rsplit(".", 1) | first | replace(".", "_") }}/$1

as we'd likely instead use the more explicit /guide/solr/latest/getting-started.html.

I see Antora has a config for whether you want a redirect from latest->9_0 or the opposite, e.g. 9_0->latest. Would it make sense to leave /latest/ in the address bar of browser, so that most links floating around would be to the latest guide? If people visit older guides, the version number will remain in address bar.

@HoustonPutman
Copy link
Contributor

yeah we probably want to leave latest in the address bar, especially because we will have redirects in the future if page names change. I wonder if that helps with our google indexing as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants