Merge "Fix deep_links macro in .htaccess"

This commit is contained in:
Zuul 2017-11-28 18:27:02 +00:00 committed by Gerrit Code Review
commit c75dd964b0
2 changed files with 9 additions and 3 deletions

View File

@ -51,7 +51,7 @@ redirectmatch {{ code }} ^{{ path }}($|/.*$) {{ result }}
code -- the response code (defaults to 301)
#}
{% macro deep_links(path, result, code=301) -%}
redirectmatch {{ code }} ^{{ path }}/?(.*)$ {{ result }}
redirectmatch {{ code }} ^{{ path }}(?![^/])/?(.*)$ {{ result }}
{%- endmacro %}
# Redirect old top-level HTML pages to the version under most recent

View File

@ -53,11 +53,17 @@
result_prefix -- the start of the new path (should not include /)
code -- the response code (defaults to 301)
#}
{% macro deep_links(path, result_prefix, code=301) -%}
{% macro deep_links(path, result_prefix, code=301, nosuffix=True) -%}
{{ path }} {{ code }} {{ result_prefix }}/
{{ path }}/ {{ code }} {{ result_prefix }}/
{{ path }}/any-page {{ code }} {{ result_prefix }}/any-page
{{ path }}/any-page.html {{ code }} {{ result_prefix }}/any-page.html
{%- if nosuffix %}
{{ path }}suffix 200
{{ path }}suffix/ 200
{{ path }}suffix/any-page 200
{{ path }}suffix/any-page.html 200
{% endif -%}
{%- endmacro %}
# Redirect old top-level HTML pages to the version under most recent
@ -102,7 +108,7 @@
# Redirect all openstack-ansible repositories appropriately
{{ deep_links('/developer/ansible-hardening', '/ansible-hardening/latest') }}
{{ deep_links('/developer/openstack-ansible-foo', '/openstack-ansible-foo/latest') }}
{{ deep_links('/developer/openstack-ansible-foo', '/openstack-ansible-foo/latest', nosuffix=False) }}
# Redirect some tripleo repositories appropriately
{{ deep_links('/developer/tripleo-common', '/tripleo-common/latest') }}