Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Then we use this variable with:

%{ENV:default_version}

Current Implementation

The first entity is the pattern to match, the second is the destination, and the third is a test URL. Prod for now doesn't use the default version and just redirects to the root. 

Our current default version is master. Either way the default version should be recent information. Queries to old pages are redirected.

Legacy URLsNew URL (desired redirect)Prod Test URLStaging Test URL
^get_started/why_mxnet.html$

%{ENV:default_version}/faq/why_mxnet.html

/versions/master/faq/why_mxnet.html

https://mxnet.incubator.apache.org/get_started/why_mxnet.htmlhttp://34.201.8.176/get_started/why_mxnet.html
^get_started.*$

%{ENV:default_version}/install/

/versions/master/install/

https://mxnet.incubator.apache.org/get_startedhttp://34.201.8.176/get_started
^how_to.*$

%{ENV:default_version}/faq/

/versions/master/faq/

https://mxnet.incubator.apache.org/how_to/http://34.201.8.176/how_to
^api/python/symbol.html$

%{ENV:default_version}/api/python/symbol/symbol.html

/versions/master/api/python/symbol/symbol.html

https://mxnet.incubator.apache.org/api/python/symbol.htmlhttp://34.201.8.176/api/python/symbol.html
^community/index.html$

%{ENV:default_version}/community/contribute.html

/versions/master/community/contribute.html

https://mxnet.incubator.apache.org/community/index.htmlhttp://34.201.8.176/community/index.html


The goal for the following section is that any request to a resource of an old version is redirected to the default version.

http://34.201.8.176/architecture should go to http://34.201.8.176/versions/master/architecture

Content that should be freshNew URL (desired redirect)Prod Test URLStaging Test URL
^versions/[^\/]+/architecture/.*$

%{ENV:default_version}/architecture/

/versions/master/architecture/

https://mxnet.incubator.apache.org/architecture

http://mxnet.incubator.apache.org/versions/1.1.0/architecture/index.html

http://34.201.8.176/architecture

http://34.201.8.176/versions/1.1.0/architecture/index.html

^versions/[^\/]+/community/.*$

%{ENV:default_version}/community/

/versions/master/community/

https://mxnet.incubator.apache.org/community/index.html

https://mxnet.incubator.apache.org/versions/1.1.0/community/contribute.html

http://34.201.8.176/community/index.html

http://34.201.8.176/versions/1.1.0/community/index.html

^versions/[^\/]+/faq/.*$

%{ENV:default_version}/faq/

/versions/master/faq/

https://mxnet.incubator.apache.org/faq/

https://mxnet.incubator.apache.org/versions/1.1.0/faq/

http://34.201.8.176/faq/

http://34.201.8.176/versions/1.1.0/faq/

^versions/[^\/]+/gluon/.*$

%{ENV:default_version}/gluon/

/versions/master/gluon/

https://mxnet.incubator.apache.org/gluon/

https://mxnet.incubator.apache.org/versions/1.1.0/gluon/

http://34.201.8.176/gluon/

http://34.201.8.176/versions/1.1.0/gluon/

^versions/[^\/]+/install/.*$

%{ENV:default_version}/install/$1

/versions/master/install/$1

https://mxnet.incubator.apache.org/install/

https://mxnet.incubator.apache.org/versions/1.1.0/install/

https://mxnet.incubator.apache.org/install/index.html?platform=MacOS&language=Clojure&processor=CPU

http://34.201.8.176/install/

http://34.201.8.176/versions/1.1.0/install/

^versions/[^\/]+/tutorials/(.*)$

%{ENV:default_version}/tutorials/$1

/versions/master/tutorials/$1

/versions/master/tutorials/gluon/mnist.html

https://mxnet.incubator.apache.org/tutorials/

https://mxnet.incubator.apache.org/tutorials/gluon/mnist.html

http://mxnet.incubator.apache.org/versions/1.2.1/tutorials/gluon/mnist.html

http://34.201.8.176/tutorials/index.html

http://34.201.8.176/versions/master/tutorials/index.html

http://34.201.8.176/tutorials/gluon/mnist.html

http://34.201.8.176/versions/1.1.0/tutorials/gluon/mnist.html

API test - this should load older content
http://mxnet.incubator.apache.org/versions/1.2.1/api/python/ndarray/ndarray.html#mxnet.ndarray.NDArray.tostype then switch versions to master. It should keep the anchor in the url.


Note that tutorials will carry the request for the particular tutorial over to the default version. Also, since some of the install links can carry a specific install type it might be good to add $1 to that one.

...

^.*(versions\/[^\/]+)?(?<!master)\/(faq|community|install|gluon|tutorials|architecture)\/(.*)$

Redirect APIs that did not exist

Finally, we have several pages for API that don't exist and it is possible for the user to navigate to them. Instead of a broken page we give them a nice 404 or error message.

...

Test URL: http://34.201.8.176/versions/0.11.0/api/clojure/

Error Pages

ErrorDocument 404 https://mxnet.incubator.apache.org/error/404.html

...

For all other APIs it should allow the queries to go through.

Error Redirect Issues

The error redirect uses a full URL instead of a local one because otherwise the error page doesn't render properly. 

Given a relative local URL like /error/404.html the error page mostly fails to render properly. If the page that didn't exist is, for example, /1/2/3/4/index.html, then the URL will be kept as such, but the 404 page will be rendered as if it is in /1/2/3/4/. The js, css, and other assets will still have URLs expecting the page to be rendered at /error/404.html, so all of those assets 404 and thus a massive fail. This could potentially be fixed by making a custom page outside of the Sphinx theme, but at this point the URLs are generated and relative to the error page's actual location.

The drawback of using a full URL is that the HTTP header shows 302, not 404. This will confuse robots into thinking that the page does exist, and it is just in a new location. Instead we really should be giving a 404.

One approach could be to fix the theme issue as mentioned above or somehow exempt the error page from regular Sphinx theming. Then the local URL could be used.

Testing Redirects

Use the following curl example from command line to see the redirect's output without having to use the browser!

curl -sSL -D - http://34.201.8.176/versions/1.1.0/tutorials/gluon/mnist.html -o /dev/null