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

Add collection redirect page and consolidate htaccess configuration files #261

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 52 additions & 12 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
ErrorDocument 404 /404.html
Options -MultiViews

RewriteEngine On

# Redirect old ansible documentation into new sub-directory

# TEMP REMOVAL TO TEST RedirectMatch permanent "^/((?!index|404)[^/]+)\.html" "/ansible/$1.html"
#####################################################################
# Permanently redirect all page URLs to /ansible/[page].html
# except for page names listed in parentheses
#####################################################################

RedirectMatch permanent "^/((?!index|404|automation.*|ansible_community|collections|community|core.*|galaxy|lint|ecosystem|users|developers|maintainers|platform|ansible-prior*)[^/]+)\.html" "/ansible/$1.html"

#####################################################################
# This section replaces rules defined for older versions that
# redirect plugin and module pages to collections. This section
# also consolidates specific redirects that were defined in multiple
# .htaccess configuration files.
#####################################################################

# Redirect plugin and module pages for devel and latest
RedirectMatch permanent "^/ansible/(devel|latest)/(plugins|modules)/(.+)\.html$" "/collections.html"
Copy link
Contributor

Choose a reason for hiding this comment

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

One big downside of this redirect is that it breaks a lot of existing links on the web (in blog posts, stack overflow answers, mailing list answers, ...) from Ansible 2.9 and before that right now still work.

I have no idea how frequently these URLs are still used though. Finding the module/plugin in question isn't too hard with the new collections.html page, though, so I guess it will be OK...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for taking a look @felixfontein I can also see this is going to hose the links to these pages: https://docs.ansible.com/ansible/latest/plugins/

I overlooked those plugin pages, but glad I caught them. I'll raise this at the next DaWGs meeting but maybe we should remove this redirect rule and avoid globbing any latest or devel urls to the collections.html page.

Either that or we add a negative lookahead for the plugin pages which do exist, such as:

RedirectMatch permanent "^/ansible/(devel|latest)/modules/(.+)\.html$" "/collections.html"
RedirectMatch permanent "^/ansible/(devel|latest)/plugins/(?!action\.html|become\.html|cache\.html|callback\.html|cliconf\.html|connection\.html|docs_fragment\.html|filter\.html|httpapi\.html|inventory\.html|lookup\.html|module\.html|module_util\.html|netconf\.html|plugins\.html|shell\.html|strategy\.html|terminal\.html|test\.html|vars\.html)/(.+)\.html$" "/collections.html"

An alternative is to take all the latest source pages and redirect them to collections using the https://pypi.org/project/sphinx-reredirects/ extension.

It doesn't remove the maintenance overhead and maybe adds to the build time. We could probably add some regex to reduce the number of redirects that we'd need and point to specific collections, for example:

redirects = {
     "modules/azure_*": "collections/azure/index.html",
}

I guess we can see but we need to rethink the devel and latest rules here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that works like a champ. I tried an experimental commit: oraNod/ansible-documentation@ec0790a

And deployed it to the test site on pages. All the latest redirects are there and it doesn't seem to add to the build time.


# Redirect plugin pages for versions 2.3 and 2.4
RedirectMatch permanent "^/ansible/(2\.[3-4])/plugins/(.+)\.html$" "/collections.html"

# Redirect module pages for versions 2.3 and 2.4
RedirectMatch permanent "^/ansible/(2\.[3-4])/([^\.]+)_module\.html$" "/collections.html"

# Redirect plugin and module pages for versions 2.5 to 2.8
RedirectMatch permanent "^/ansible/(2\.[5-8])/(plugins|modules)/(.+)\.html$" "/collections.html"

# Vault redirects (2.3, 2.4, 2.5, 2.6)
RedirectMatch permanent "^/ansible/(2\.(5|6))/user_guide/playbooks_vault.html" "/ansible/latest/vault_guide/index.html"
RedirectMatch permanent "^/ansible/(2\.[3-4])/playbooks_vault.html" "/ansible/latest/vault_guide/index.html"

# 2.3 and 2.4 specific redirects
RedirectMatch permanent "^/ansible/(2\.([3-4]))/playbooks_roles.html" "/ansible/latest/playbook_guide/playbooks_reuse.html"
RedirectMatch permanent "^/ansible/(2\.([3-4]))/playbooks_directives.html" "/ansible/latest/reference_appendices/playbooks_keywords.html"
RedirectMatch permanent "^/ansible/(2\.([3-4]))/dev_guide/developing_test_pr.html" "/ansible/latest/dev_guide/testing.html"

# 2.6 specific redirects
RedirectMatch permanent "^/ansible/2.6/user_guide/quickstart.html" "/ansible/latest/getting_started/index.html"
RedirectMatch permanent "^/ansible/2.6/vmware/index.html" "/ansible/latest/collections/community/vmware/index.html"

# EOL Archive Redirects for all the rest
RedirectMatch permanent "^/ansible/(2\.(10|[3-8]))/(.+)\.html$" "/ansible/latest/$3.html"

#####################################################################
# Redirects for top-level project pages
#####################################################################

# Redirect the lint and galaxy pages to the ecosystem page

RedirectMatch permanent "/galaxy.html" "/ecosystem.html"
Expand All @@ -17,11 +58,19 @@ RedirectMatch permanent "/lint.html" "/ecosystem.html"

RedirectMatch permanent "/automation.html" "/platform.html"

# Redirect all ansible-lint pages to ReadTheDocs

RedirectMatch permanent "^/ansible-lint/*" "https://ansible.readthedocs.io/projects/lint/"

# Redirect so docs.ansible.com/ansible-core/ and docs.ansible.com/ansible/ dont show an Index of page anymore

RedirectMatch permanent "^/ansible-core(|/|/index.html)$" "/ansible-core/devel/"
RedirectMatch permanent "^/ansible(|/|/index.html)$" "/ansible/latest/"

#####################################################################
# Redirects for pages that have moved
#####################################################################

# Redirect developer docs to new dir

RedirectMatch permanent "^/ansible/(developing_[^/]+)\.html" "/ansible/latest/dev_guide/$1.html"
Expand All @@ -31,10 +80,6 @@ RedirectMatch permanent "^/ansible/dev_guide(\/)?" "/ansible/latest/dev_guide/in
# Redirect from PR #79562
RedirectMatch permanent "^/ansible/(devel|latest)/dev_guide/testing_compile.html" "/ansible/$1/dev_guide/testing/sanity/compile.html"

# Commenting out the regex below; it redirected Ansible 3.0.0 docs (URLs like /ansible/3/*)

# RedirectMatch permanent "^/ansible/(?!latest|devel|\d\.+)(.+)?.html" "/ansible/latest/$1.html"

# Redirects for renamed module reference directory

RedirectMatch permanent "^/ansible/devel/module_docs/?(.+)?" "/ansible/devel/modules/$1"
Expand Down Expand Up @@ -362,8 +407,3 @@ RedirectMatch permanent "^/ansible/(devel|latest)/vmware/vmware_?(.+)?" "/ansibl
# Redirect old support pages per request from product team

RedirectMatch permanent "^\/ansible-tower\/((2\.\d\.\d)|3\.[0-3]\.\d)\/html(_\w+)?\/.*updates_support\.html$" "/ansible-tower/latest/html$3/installandreference/updates_support.html"

# Redirect all ansible-lint pages to ReadTheDocs

RedirectMatch permanent "^/ansible-lint/*" "https://ansible-lint.readthedocs.io"

Loading
Loading