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

SOLR-15557 Script to generate refguide page .htaccess redirects #596

Merged

Conversation

janhoy
Copy link
Contributor

@janhoy janhoy commented Feb 4, 2022

https://issues.apache.org/jira/browse/SOLR-15557

See apache/solr-site#70 for the output of this script given the input files as of today

I added the output to this PR so it is easier to iterate in one PR and make review comments on the htaccess.txt directly. For every edit you make, please run this command before committing.

python3 gen-refguide-redirects.py --old old-guide.txt --new new-guide.txt --mapping mappings.csv --htaccess >htaccess.txt

@HoustonPutman
Copy link
Contributor

I think you deleted the script in your last commit...

@janhoy
Copy link
Contributor Author

janhoy commented Feb 4, 2022

I think you deleted the script in your last commit...

Yea, moved it into the folder, but forgot to git add it :) Now it's back

@janhoy
Copy link
Contributor Author

janhoy commented Feb 4, 2022

Did a bunch of 8_11 mappings, now there are only 25 pages left without a mapping. Some should point to landing pages which still does not exist in the new guide I think.

@janhoy
Copy link
Contributor Author

janhoy commented Feb 6, 2022

Now tested this on a real httpd server, with a new guide/.htaccess. Made adjustments to the rules based on that (Anchor with ^ and use relative names).

Combined regex for each of the new sub paths
Separate section for 8_11 redirects
@janhoy
Copy link
Contributor Author

janhoy commented Feb 7, 2022

Separate htaccess did not play out as intended. Going back to using top-level one. Also merged the sub-path renames into larger regex lines, and separated 8_11 guide redirects into its own section.

if conf.htaccess:
print("# Existing pages moved to sub path")
for key in regex_new:
print("RedirectMatch ^/guide/(%s)\.html /guide/%s/$1.html" % ("|".join(regex_new[key]), key))
Copy link
Contributor

Choose a reason for hiding this comment

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

The new Solr Ref Guide pages are going to have the structure: /guide/solr/<version>/page.html. (This includes a /solr/ after /guide/). And the guide will support the version tag latest that will redirect to the latest version that has been published. Therefore these should link to /guide/solr/latest/<page>.html (this line and the rewrite rule below it)

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, will add the /solr/ level, and latest version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I presume that the already existing guides will continue to live at /guide/<version>/?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that presumption is correct I think.

Also, Antora is going to create another htaccess file to redirect stuff itself (including /guide/solr/latest -> /guide/solr/9_0). Everytime I look at htaccess, I've forgotten what I learned the previous time. Will these new rules make it so that the browser does two redirects, old-url -> /guide/solr/latest and then the browser issues another request: /guide/solr/latest -> /guide/solr/9_0? Or will htaccess do the 2 redirects itself and give the browser old-url -> /guide/solr/9_0?

Copy link
Contributor

Choose a reason for hiding this comment

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

This question is not a blocker, at least not for now. Easiest path forward to make this stuff work, I just wanted to better understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Multi layers of .htaccess is hard to get right. The Antora folders will all reside in svn in the folder pointed to by __root/docs.solr.apache.org/guide, so I don't even know if httpd will execute .htaccess from there. If httpd finds a .htaccess file on a deep level, it will use that one instead of the topmost one, and if you try to inherit, then all the rules form top-level stop working.

So I think we have to put all rules in our main htaccess file, including the latest -> 9_0 one. At the end, we'll simply have to try and see what happens.

@janhoy
Copy link
Contributor Author

janhoy commented May 12, 2022

Brought this up to date with latest bugfix. Should we perhaps merge it, so it can be used as basis for a future similar endeavor?

@HoustonPutman HoustonPutman merged commit df84356 into apache:main May 12, 2022
@janhoy janhoy deleted the SOLR-15557-script-to-generate-redirects branch September 7, 2023 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants