You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2015/10/30 20:00:00 UTC
docs commit: Replacing old redirect files with RewriteRules in
.htaccess.
Repository: cordova-docs
Updated Branches:
refs/heads/master 56b437b11 -> 3e1cd937c
Replacing old redirect files with RewriteRules in .htaccess.
Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/3e1cd937
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/3e1cd937
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/3e1cd937
Branch: refs/heads/master
Commit: 3e1cd937cc0b4f7c0000c68758cb919dbd03b94c
Parents: 56b437b
Author: Dmitry Blotsky <dm...@gmail.com>
Authored: Tue Oct 27 20:44:37 2015 -0700
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Thu Oct 29 17:48:47 2015 -0700
----------------------------------------------------------------------
_config.yml | 6 +++++-
www/.htaccess | 47 +++++++++++++++++++++++++++++++++++------------
2 files changed, 40 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/3e1cd937/_config.yml
----------------------------------------------------------------------
diff --git a/_config.yml b/_config.yml
index c725c7c..e87d01e 100644
--- a/_config.yml
+++ b/_config.yml
@@ -12,9 +12,13 @@ repo:
uri: https://github.com/apache/cordova-docs
branch: master
+# NOTE:
+# this value gets overwritten in _version.yml, which is a generated file
latest_docs_version: edge
-# NOTE: defaults are configured in _defaults.yml, which is a generated file
+# NOTE:
+# this value gets overwritten in _defaults.yml, which is a generated file
+defaults:
# =======
# Build settings
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/3e1cd937/www/.htaccess
----------------------------------------------------------------------
diff --git a/www/.htaccess b/www/.htaccess
index 66d177e..b7bce8b 100644
--- a/www/.htaccess
+++ b/www/.htaccess
@@ -1,24 +1,47 @@
---
---
-ErrorDocument 404 {{ site.baseurl }}/404.html
+ErrorDocument 404 {{site.baseurl}}/404.html
-# Redirects for old docs pages
+# turn on redirection
Options +FollowSymLinks
RewriteEngine on
-# only bother applying the below rules for docs pages
# NOTE:
-# the leading slash is optional, so it has a '?' before it
-RewriteCond %{REQUEST_URI} ^.*{{ site.baseurl }}/?docs/.*$
+# 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.
-# create a 301 mapping with a RewriteRule for each
-# docs redirect specified in _data/docs-redirects.yml
+# 302:
+# docs -> docs/en/latest/
+# docs/ -> docs/en/latest/
+# docs/XX -> docs/XX/latest/
+# docs/XX/ -> docs/XX/latest/
+#
# NOTE:
-# the leading slash is optional because sometimes
-# REQUEST_URI doesn't contain it
+# these can both apply, turning "/docs" into "/docs/en/latest/"
+RewriteRule ^.*docs/$ {{site.baseurl}}/docs/en/
+RewriteRule ^.*docs/(\w\w)/$ {{site.baseurl}}/docs/$1/latest/ [R=302]
+
+# 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/(\w\w)/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. $1) is not used because the new
-# URI's prefix is known and fixed by us (i.e. baseurl/docs/...)
+# The first part of the path (i.e. the ".*") is
+# thrown away and replaced by site.baseurl.
{% for redirect in site.data.docs-redirects %}
-RewriteRule ^.*(/?)docs/([^/]{2,2})/([^/]+)/{{ redirect.old }}$ {{ site.baseurl }}/docs/$2/$3/{{ redirect.new }} [R=301]{% endfor %}
+RewriteRule ^.*docs/(\w\w)/([^/]+)/{{redirect.old}}$ {{site.baseurl}}/docs/$1/$2/{{redirect.new}} [R=301]{% endfor %}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org