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

csantanapr/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/dev/, /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
#       pages to new pages.

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

# 301 (perm):
#       docs/XX/edge  -> docs/xx/edge/
#       docs/XX/edge/ -> docs/xx/dev/
RewriteRule ^.*docs/(ww)/edge$ {{site.baseurl}}/docs/$1/edge/
RewriteRule ^.*docs/(ww)/edge/(.*)$ {{site.baseurl}}/docs/$1/dev/$2 [R=301,L]

# 301 (perm):
#       docs version renames
RewriteRule ^.*docs/(ww)/6.0.0/(.*)$ {{site.baseurl}}/docs/$1/6.x/$2 [R=301,L]

# 301 (perm):
#       old docs pages -> new docs pages (global)
#
# NOTE:
#       The first part of the path (i.e. the ".*") is thrown away and replaced
#       by site.baseurl. It is thrown away because there is no RewriteCond to
#       control whether the rewrite happens to a URI or a local file path
#       (when Apache is locating the local file to serve).
{% for redirect in site.data.redirects.docs-global %}RewriteRule ^.*docs/(ww)/([^/]+)/{{redirect.old}}$ {{site.baseurl}}/docs/$1/$2/{{redirect.new}} [NE,R=301,L]
{% endfor %}

# 301 (perm):
#       old docs pages -> new docs pages (version-specific)
{% for redirect in site.data.redirects.docs %}RewriteRule ^.*docs/(ww)/{{redirect.old}}$ {{site.baseurl}}/docs/$1/{{redirect.new}} [NE,R=301,L]
{% endfor %}

# 301 (perm):
#       old pages -> new pages
{% for redirect in site.data.redirects.general %}RewriteRule ^.*/{{redirect.old}}$ {{site.baseurl}}/{{redirect.new}} [NE,R=301,L]
{% endfor %}

# 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).
# NOTE:
#       This needs to be *after* the docs redirects because they might need the
#       "/latest/" to be in the URI in order to activate. Placing this rule
#       before them will rewrite "/latest/" to the latest version and redirects
#       for "/latest/some/path.html" will never activate.
RewriteRule ^.*docs/(ww)/latest/(.*)$ {{site.baseurl}}/docs/$1/{{site.latest_docs_version}}/$2 [L]

On Github License

Files

Download PDF of Htaccess file

Comments

Apache