dubeejw/cordova-docs/master/www/.htaccess - Htaccess File

dubeejw/cordova-docs/master/www/.htaccess

---
---

ErrorDocument 404 {{site.baseurl}}/404.html

# turn on redirection
Options +FollowSymLinks
RewriteEngine on

# NOTE:
#       Some of the below redirects are 302s, and some are 301s. 302s are used
#       for redirects whose targets change sometimes. For example:
#           - /docs/          -> /docs/fr/, /docs/en/, etc.
#           - /docs/en/       -> /docs/en/edge/, /docs/en/latest/, etc.
#           - /docs/en/latest -> /docs/en/4.0.0/, /docs/en/5.0.0/, etc.
#
#       301s are for PERMANENT redirects. These are used only for mapping old
#       docs pages to new docs pages.

# 302:
#       docs     -> docs/en/latest/
#       docs/    -> docs/en/latest/
#       docs/XX  -> docs/XX/latest/
#       docs/XX/ -> docs/XX/latest/
#
# NOTE:
#       these can both apply, turning "/docs" into "/docs/en/latest/"
RewriteRule ^.*docs/$ {{site.baseurl}}/docs/en/
RewriteRule ^.*docs/(ww)/$ {{site.baseurl}}/docs/$1/latest/ [R=302,L]

# 302:
#       docs/XX/latest -> docs/XX/latest/
RewriteRule ^.*docs/(ww)/latest$ {{site.baseurl}}/docs/$1/latest/ [R=302,L]

# rewrite only:
#       /docs/XX/latest/* -> /docs/XX/Y.Y.Y/*
#
# NOTE:
#       This does NOT return a redirect. It returns the resource *as if* the
#       redirected URI was requested. That is, both URIs return the same
#       resource, but the browser won't change the URI (no redirects followed).
RewriteRule ^.*docs/(ww)/latest/(.*)$ {{site.baseurl}}/docs/$1/{{site.latest_docs_version}}/$2 [L]

# 301:
#       old docs pages -> new docs pages (from www/_data/docs-redirects.yml)
#
# NOTE:
#       The first part of the path (i.e. the ".*") is
#       thrown away and replaced by site.baseurl.
# NOTE:
#       The reason for this not just being "redirects" and rather being
#       docs-specific is: these redirects happen for every version of the
#       docs. That's 157 redirects * 84 versions ~= 13000 redirects! Doing
#       special pattern-matching for docs keeps that number at _only_ 157.
{% for redirect in site.data.docs-redirects %}
RewriteRule ^.*docs/(ww)/([^/]+)/{{redirect.old}}$ {{site.baseurl}}/docs/$1/$2/{{redirect.new}} [R=301,L]{% endfor %}

On Github License

Files

Download PDF of Htaccess file

Comments

Apache