diff --git a/conf.py b/conf.py index c0101d1e6c05bd7eadac190c7391b2ba3f1c9aad..cf2c41a832ffc2647e9212f8e61fea4fcadcb50d 100644 --- a/conf.py +++ b/conf.py @@ -372,7 +372,7 @@ REDIRECTIONS = [] DEPLOY_COMMANDS = { 'default': [ "rsync -rlv -e 'ssh -i deploy_key' --delete --filter 'P doc/*' output/* kwant@kwant-project.org:", - "rsync -lv -e 'ssh -i deploy_key' htaccess-apache kwant@kwant-project.org:/.htaccess", + "rsync -lv -e 'ssh -i deploy_key' nginx.conf kwant@kwant-project.org:/nginx.conf", ] } diff --git a/htaccess-apache b/htaccess-apache deleted file mode 100644 index 19b84389c79d12c5d9639a78141514bd2c89cde7..0000000000000000000000000000000000000000 --- a/htaccess-apache +++ /dev/null @@ -1,47 +0,0 @@ -<IfModule mod_mime.c> -AddType image/svg+xml svg svgz -AddEncoding gzip svgz -</IfModule> - -# Do not treat Python files as CGI scripts. -<FilesMatch \.py$> - SetHandler default-handler -</FilesMatch> - -RewriteEngine on - -# We don't need more than that. -RewriteOptions MaxRedirects=2 - -# Redirect /foo/index.html to /foo/ -RewriteRule ^(|.*/)index\.html$ /$1 [R=301,L] - -# Redirect /foo/bar.html to /foo/bar only if a html file was requested by the -# browser. Without the condition the following rewrite rule leads to a -# redirection loop. -RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/ -RewriteRule ^(.*)\.html$ /$1 [R=301,L] - -# Rewrite /foo/bar to /foo/bar.html if the latter exists. -RewriteCond %{REQUEST_FILENAME}.html -f -RewriteRule ^(.*[^/])$ /$1.html [L] - -# Remove trailing slash if the requested directory does not exist. -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)/$ /$1 [R=301,L] - -Redirect 302 /contact /doc/latest/pre/authors -Redirect 302 /authors /doc/latest/pre/authors -Redirect 302 /citing /doc/latest/pre/citing -Redirect 302 /cite /doc/latest/pre/citing -Redirect 302 /license /doc/latest/pre/license -Redirect 302 /download /install - -# Redirect old tutorial URLs to new ones. -# The tutorial numbers refer to the tutorial enumeration in Kwant 1.2.x -Redirect 302 /doc/1/tutorial/tutorial1 /doc/1/tutorial/first_steps -Redirect 302 /doc/1/tutorial/tutorial2 /doc/1/tutorial/spin_potential_shape -Redirect 302 /doc/1/tutorial/tutorial3 /doc/1/tutorial/spectrum -Redirect 302 /doc/1/tutorial/tutorial4 /doc/1/tutorial/graphene -Redirect 302 /doc/1/tutorial/tutorial5 /doc/1/tutorial/superconductor -Redirect 302 /doc/1/tutorial/tutorial6 /doc/1/tutorial/plotting diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..948437ec71869887fc1b32759babe1569279be8b --- /dev/null +++ b/nginx.conf @@ -0,0 +1,55 @@ +## Generic rules ## +# try exact URI, then directory, then HTML document. +location / { + try_files $uri $uri.html $uri/ @root-redirect; +} +location @root-redirect { + rewrite ^/contact$ /doc/latest/pre/authors permanent; + rewrite ^/authors$ /doc/latest/pre/authors permanent; + rewrite ^/citing$ /doc/latest/pre/citing permanent; + rewrite ^/cite$ /doc/latest/pre/citing permanent; + rewrite ^/license$ /doc/latest/pre/license permanent; + rewrite ^/download$ /install permanent; +} + +## Prettify URLs ## +#redirect */index.html => */ and *.html => * +rewrite ^(.*/)index.html $1 permanent; +rewrite ^(.*[^/])\.html$ $1 permanent; +# For folders, initially look for /index.html +location ~ ^(.*)/$ { + try_files $1/index.html @folder-redirect; +} +# else try removing the trailing slash +location @folder-redirect { + rewrite ^(.*)/ $1 permanent; +} + + +## Specific rules ## +# serve compressed svg correctly +location ~ \.svgz$ { + add_header Content-Encoding gzip; + add_header Content-Type image/svg+xml; +} + +# make sure that we don't serve this configuration file! +location /nginx.conf { + return 404; +} + +## Tutorial redirects ## + +location /doc/1/tutorial { + try_files $uri $uri/ $uri.html @tutorial-redirect; +} +# Redirect old tutorial URLs to new ones. +# The tutorial numbers refer to the tutorial enumeration in Kwant 1.2.x +location @tutorial-redirect { + rewrite ^/doc/1/tutorial/tutorial1$ /doc/1/tutorial/first_steps permanent; + rewrite ^/doc/1/tutorial/tutorial2$ /doc/1/tutorial/spin_potential_shape permanent; + rewrite ^/doc/1/tutorial/tutorial3$ /doc/1/tutorial/spectrum permanent; + rewrite ^/doc/1/tutorial/tutorial4$ /doc/1/tutorial/graphene permanent; + rewrite ^/doc/1/tutorial/tutorial5$ /doc/1/tutorial/superconductor permanent; + rewrite ^/doc/1/tutorial/tutorial6$ /doc/1/tutorial/plotting permanent; +}