Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split d.p.o redirects to a new config file #504

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 3 additions & 215 deletions salt/docs/config/nginx.docs-backend.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,221 +16,9 @@ server {

autoindex on;

# Python 3 docs are the default at the root.
location = / {
return 302 $scheme://$host/3/;
}

# Python 3 docs are the default at the root of each translations.
location ~ ^/(es|fr|id|it|ja|ko|pl|pt-br|tr|uk|zh-cn|zh-tw)/$ {
return 302 $scheme://$host/$1/3/;
}

# Pretty 404 for archives telling to wait for them to be built.
location ~ \.(pdf|zip|epub|bz2)$ {
error_page 404 /404.html;
}

# Some doc download pages link to docs.python.org/ftp instead of www.python.org/ftp.
location ^~ /ftp/ {
return 301 https://www.python.org$request_uri;
}

location ~ /py3k(.*)$ {
return 301 https://$host/3$1;
}

# Smooth the switch between versions by mapping old files to their new location
location ~ ^/([a-z-]*/)?(3|3.6|3.7|3.8)/library/email.util.html$ {
return 301 https://$host/$1$2/library/email.utils.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/c-api/(class|cobject|int|string).html$ {
return 301 https://$host/$1$2/c-api/;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/howto/(doanddont|webservers).html$ {
return 301 https://$host/$1$2/;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/(aepack|aetools|aetypes|al|autogil|bastion|bsddb|carbon|cd|colorpicker|commands|compiler|dbhash|dircache|dl|dummy_thread|easydialogs|fl|fm|fpectl|fpformat|framework|future_builtins|gensuitemodule|gl|hotshot|htmllib|ic|imageop|imgfile|imputil|jpeg|mac|macos|macosa|macostools|md5|mhlib|mimetools|mimewriter|mimify|miniaeframe|multifile|mutex|new|popen2|posixfile|restricted|rexec|rfc822|sgi|sgmllib|sha|someos|statvfs|sun|sunaudio|user).html$ {
return 301 https://$host/$1$2/;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/strings.html$ {
return 301 https://$host/$1$2/library/text.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/stringio.html$ {
return 301 https://$host/$1$2/library/io.html#io.StringIO;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/sets.html$ {
return 301 https://$host/$1$2/library/stdtypes.html#set-types-set-frozenset;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/userdict.html$ {
return 301 https://$host/$1$2/library/collections.html#userdict-objects;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/repr.html$ {
return 301 https://$host/$1$2/library/reprlib.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/copy_reg.html$ {
return 301 https://$host/$1$2/library/copyreg.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/anydbm.html$ {
return 301 https://$host/$1$2/library/dbm.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/whichdb.html$ {
return 301 https://$host/$1$2/library/dbm.html#dbm.whichdb;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/dumbdbm.html$ {
return 301 https://$host/$1$2/library/dbm.html#module-dbm.dumb;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/gdbm.html$ {
return 301 https://$host/$1$2/library/dbm.html#module-dbm.gnu;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/robotparser.html$ {
return 301 https://$host/$1$2/library/urllib.robotparser.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/thread.html$ {
return 301 https://$host/$1$2/library/_thread.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/email-examples.html$ {
return 301 https://$host/$1$2/library/email.examples.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/htmlparser.html$ {
return 301 https://$host/$1$2/library/html.parser.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/urllib2.html$ {
return 301 https://$host/$1$2/library/urllib.request.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/httplib.html$ {
return 301 https://$host/$1$2/library/http.client.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/urlparse.html$ {
return 301 https://$host/$1$2/library/urllib.parse.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/basehttpserver.html$ {
return 301 https://$host/$1$2/library/http.server.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/simplehttpserver.html$ {
return 301 https://$host/$1$2/library/http.server.html#http.server.SimpleHTTPRequestHandler;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/cgihttpserver.html$ {
return 301 https://$host/$1$2/library/http.server.html#http.server.CGIHTTPRequestHandler;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/cookielib.html$ {
return 301 https://$host/$1$2/library/http.cookiejar.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/cookie.html$ {
return 301 https://$host/$1$2/library/http.cookies.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/xmlrpclib.html$ {
return 301 https://$host/$1$2/library/xmlrpc.client.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/simplexmlrpcserver.html$ {
return 301 https://$host/$1$2/library/xmlrpc.server.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/docxmlrpcserver.html$ {
return 301 https://$host/$1$2/library/xmlrpc.server.html#documenting-xmlrpc-server;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/ttk.html$ {
return 301 https://$host/$1$2/library/tkinter.ttk.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/tix.html$ {
return 301 https://$host/$1$2/library/tkinter.tix.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/scrolledtext.html$ {
return 301 https://$host/$1$2/library/tkinter.scrolledtext.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/__builtin__.html$ {
return 301 https://$host/$1$2/library/builtins.html;
}
location ~ ^/([a-z-]*/)?(3|3.5|3.6|3.7|3.8|3.9|3.10)/library/_winreg.html$ {
return 301 https://$host/$1$2/library/winreg.html;
}
location ~ ^/([a-z-]*/)?(3|3.12|3.13|3.14)/library/(asynchat|asyncore|smtpd).html$ {
return 301 https://$host/$1$2/;
}
location ~ ^/([a-z-]*/)?(3.13|3.14)/library/(2to3|aifc|audioop|cgi|cgitb|chunk|crypt|imghdr|mailcap|msilib|nis|nntplib|ossaudiodev|pipes|sndhdr|spwd|sunau|telnetlib|tkinter.tix|uu|xdrlib).html$ {
return 301 https://$host/$1$2/;
}

# Map /documenting to the devguide.
location ~ ^/devguide/(.*)$ {
return 301 https://devguide.python.org/$1;
}
location = /documenting/ {
return 301 https://devguide.python.org/documentation/start-documenting/;
}
location = /documenting/index.html {
return 301 https://devguide.python.org/documentation/start-documenting/;
}
location = /documenting/intro.html {
return 301 https://devguide.python.org/documentation/start-documenting/#introduction;
}
location = /documenting/style.html {
return 301 https://devguide.python.org/documentation/style-guide/;
}
location = /documenting/rest.html {
return 301 https://devguide.python.org/documentation/markup/;
}
location = /documenting/markup.html {
return 301 https://devguide.python.org/documentation/markup/;
}
location = /documenting/fromlatex.html {
return 301 https://devguide.python.org/documentation/markup/;
}
location = /documenting/building.html {
return 301 https://devguide.python.org/documentation/start-documenting/#building-the-documentation;
}

# Map toplevel URIs to Python 3 docs.
location ~ ^/((archives|c-api|distutils|extending|faq|howto|install|library|reference|tutorial|using|whatsnew|_images|_sources|_static)(/.*)?)$ {
return 301 https://$host/3/$1;
}
location ~ ^/(about|bugs|contents|copyright|download|genindex.*|glossary|index|license|py-modindex|search)(.html)?$ {
return 301 https://$host/3/$1.html;
}
location ~ ^/(searchindex.js|objects.inv)$ {
return 301 https://$host/3/$1;
}

# Emulate Apache's content-negotiation. Was a temporary measure,
# but now people are using it like a feature.
# Redirect ``$request_uri`` -> ``$request_uri.html``,
# where the latter is a valid webpage.
location ~ ^/((2|3)(\.[0-9]+)?|dev)/\w+/[\d\w\.]+(?!\.html)$ {
if (-f "${request_filename}.html") {
return 301 https://$host:$request_uri.html;
}
}

# Map old, 2.5-and-earlier directory names to 2.6-and-later names.
location = /lib/ {
return 301 https://$host/library/;
}
location ~ ^/lib/module-([a-zA-Z0-9.]+)\.html$ {
return 301 https://$host/library/$1.html;
}
location = /tut/ {
return 301 https://$host/tutorial/;
}
location = /tut/tut.html {
return 301 https://$host/tutorial/;
}
location = /api/ {
return 301 https://$host/c-api/;
}
location = /ext/ {
return 301 https://$host/extending/;
}
location = /dist/ {
return 301 https://docs.python.org/distutils/;
}
location = /inst/ {
return 301 https://$host/install/;
}
location = /doc/ {
return 301 https://devguide.python.org/documenting.html;
}
location = /ref/ {
return 301 https://$host/reference/;
}
# The redirect config for docs.python.org is in a separate file
# to allow automatic testing via Hurl (https://hurl.dev/)
include docs-redirects.conf;
}

server {
Expand Down
Loading
Loading