skip redirects when code name matches service type

The ec2-api project docs aren't accessible because /ec2-api/ redirects
to /ec2-api/latest/ (due to the rule about project URLs without a
series) and /ec2-api/.* redirects to /ec2-api/latest/ (due to the rule
for service types). The combination ensures that accessing
docs.o.o/ec2-api/ results in an infinite redirect loop. This change
breaks the loop by skiping the service type rule when the service type
and project name match.

Change-Id: I79e869b12cbd33f79cd1455d9aa26ec5a6642429
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2017-07-14 12:28:45 -04:00
parent d550f7d517
commit f7b5b56b34

View File

@ -66,7 +66,7 @@ redirectmatch 301 "^/cli-reference/.*$" /python-openstackclient/latest/
# Redirects from service-type to code-name
{% for project in projects -%}
{%- if project.type == 'service' and project.service_type %}
{%- if project.type == 'service' and project.service_type and (project.service_type|lower != project.name) %}
redirectmatch 302 "^/{{project.service_type|lower}}/.*$" /{{project.name}}/latest/
{%- endif %}
{%- endfor %}