From 1bad9c521242e4231ca1c8542cac0a817d6da671 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 1 Oct 2025 14:44:39 +0000 Subject: [PATCH] Use HTTP/302 temporary redirects for versions Redirects from unversioned to versioned pages should rely on temporary redirects because these change from one release cycle to the next. Permanent redirects result in browsers holding onto the redirected path indefinitely, at least until they forget them, which could still be a very long time. Change-Id: I22715d9c1248da73c2fbecd8f37fdd80688a2685 Signed-off-by: Jeremy Stanley --- www/.htaccess | 20 ++++++++++---------- www/redirect-tests.txt | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/www/.htaccess b/www/.htaccess index 31d1a3eff9..33688f1989 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -34,9 +34,9 @@ redirectmatch {{ code }} ^{{ path }}($|/.*$) {{ result }} Arguments: path -- the partial regex representing the input path (should not end in /) result -- the subdirectory under /RELEASED_SERIES, (should start with /) - code -- the response code (defaults to 301) + code -- the response code (defaults to 302) #} -{% macro path_to_released_series(path, result, code=301) -%} +{% macro path_to_released_series(path, result, code=302) -%} {{ path_to_page(path, '/' + RELEASED_SERIES + result, code) }} {%- endmacro %} @@ -66,16 +66,16 @@ redirectmatch {{ code }} ^{{ path }}(?![^/])/?(.*)$ {{ result }} # Redirect old top-level HTML pages to the version under most recent # full release. -redirectmatch 301 ^/$ /{{ RELEASED_SERIES }}/ -redirectmatch 301 ^/index.html$ /{{ RELEASED_SERIES }}/ -redirectmatch 301 ^/openstack-projects.html$ /{{ RELEASED_SERIES }}/projects.html -redirectmatch 301 ^/language-bindings.html$ /{{ RELEASED_SERIES }}/language-bindings.html +redirectmatch 302 ^/$ /{{ RELEASED_SERIES }}/ +redirectmatch 302 ^/index.html$ /{{ RELEASED_SERIES }}/ +redirectmatch 302 ^/openstack-projects.html$ /{{ RELEASED_SERIES }}/projects.html +redirectmatch 302 ^/language-bindings.html$ /{{ RELEASED_SERIES }}/language-bindings.html # Redirect docs.openstack.org index.html subpage pointers to main page -{{ dir_to_page('/install', '/' + RELEASED_SERIES + '/install/') }} -{{ dir_to_page('/basic-install', '/' + RELEASED_SERIES + '/install/') }} +{{ dir_to_page('/install', '/' + RELEASED_SERIES + '/install/', 302) }} +{{ dir_to_page('/basic-install', '/' + RELEASED_SERIES + '/install/', 302) }} {{ dir_to_page('/run', '/') }} -redirect 301 /developer/index.html /{{ RELEASED_SERIES }}/projects.html +redirect 302 /developer/index.html /{{ RELEASED_SERIES }}/projects.html {{ dir_to_page('/cli', '/') }} redirect 301 /api/api-specs.html https://docs.openstack.org/api-quick-start/index.html @@ -140,7 +140,7 @@ redirect 301 /openstack-ansible-lxc_container_create/ocata/ /openstack-ansible-l {{ path_to_released_series('/trunk/openstack-ops', '/admin/') }} # Redirect api list -{{ deep_links('/api', '/' + RELEASED_SERIES + '/api/') }} +{{ deep_links('/api', '/' + RELEASED_SERIES + '/api/', 302) }} # Redirect missing project page for openstack-charms {{ path_to_page('/openstack-charms', '/charm-guide/') }} diff --git a/www/redirect-tests.txt b/www/redirect-tests.txt index 6141547c9e..cf290f9de9 100644 --- a/www/redirect-tests.txt +++ b/www/redirect-tests.txt @@ -37,9 +37,9 @@ Arguments: path -- the partial regex representing the input path (should not end in /) result -- the subdirectory under /RELEASED_SERIES, (should start with /) - code -- the response code (defaults to 301) + code -- the response code (defaults to 302) #} -{% macro path_to_released_series(path, result, code=301) -%} +{% macro path_to_released_series(path, result, code=302) -%} {{ path_to_page(path, '/' + RELEASED_SERIES + result, code) }} {%- endmacro %} @@ -78,16 +78,16 @@ # Redirect old top-level HTML pages to the version under most recent # full release. -/ 301 /{{ RELEASED_SERIES }}/ -/index.html 301 /{{ RELEASED_SERIES }}/ -/openstack-projects.html 301 /{{ RELEASED_SERIES }}/projects.html -/language-bindings.html 301 /{{ RELEASED_SERIES }}/language-bindings.html +/ 302 /{{ RELEASED_SERIES }}/ +/index.html 302 /{{ RELEASED_SERIES }}/ +/openstack-projects.html 302 /{{ RELEASED_SERIES }}/projects.html +/language-bindings.html 302 /{{ RELEASED_SERIES }}/language-bindings.html # Redirect docs.openstack.org index.html subpage pointers to main page -{{ dir_to_page('/install', '/' + RELEASED_SERIES + '/install/') }} -{{ dir_to_page('/basic-install', '/' + RELEASED_SERIES + '/install/') }} +{{ dir_to_page('/install', '/' + RELEASED_SERIES + '/install/', 302) }} +{{ dir_to_page('/basic-install', '/' + RELEASED_SERIES + '/install/', 302) }} {{ dir_to_page('/run', '/') }} -/developer/index.html 301 /{{ RELEASED_SERIES }}/projects.html +/developer/index.html 302 /{{ RELEASED_SERIES }}/projects.html {{ dir_to_page('/cli', '/') }} /api/api-specs.html 301 https://docs.openstack.org/api-quick-start/index.html @@ -192,7 +192,7 @@ /doc-contrib-guide/ui-text-guidelines 301 /doc-contrib-guide/ux-ui-guidelines # Redirect any deploy guide project directory back to the current stable index -{{ dir_to_page('/project-deploy-guide', '/' + RELEASED_SERIES + '/deploy/') }} +{{ dir_to_page('/project-deploy-guide', '/' + RELEASED_SERIES + '/deploy/', 302) }} # Redirect all the project deploy folders to their appropriate branch {# newton is a special case because it exists but is not maintained #} {{ dir_to_page('/project-deploy-guide/newton', '/newton/deploy/') }}