From 21b666028c3d408695c35a7e9f45b2eacfb9c016 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Wed, 25 Nov 2015 17:43:47 +0100
Subject: [PATCH] add htaccess and modify deploy command

---
 conf.py         | 11 ++++++-----
 htaccess-apache | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 5 deletions(-)
 create mode 100644 htaccess-apache

diff --git a/conf.py b/conf.py
index 8607ccf..6a8f705 100644
--- a/conf.py
+++ b/conf.py
@@ -407,11 +407,12 @@ REDIRECTIONS = []
 # to `nikola deploy`.  If no arguments are specified, a preset
 # named `default` will be executed.  You can use as many presets
 # in a `nikola deploy` command as you like.
-# DEPLOY_COMMANDS = {
-#     'default': [
-#         "rsync -rav --delete output/ joe@my.site:/srv/www/site",
-#     ]
-# }
+DEPLOY_COMMANDS = {
+    'default': [
+        "rsync -rav --delete --filter 'P /doc' output/ <USER@TARGET/DIR>",
+        "rsync -av htaccess-apache <USER@TARGET/DIR>/.htaccess",
+    ]
+}
 
 # For user.github.io OR organization.github.io pages, the DEPLOY branch
 # MUST be 'master', and 'gh-pages' for other repositories.
diff --git a/htaccess-apache b/htaccess-apache
new file mode 100644
index 0000000..bc29f98
--- /dev/null
+++ b/htaccess-apache
@@ -0,0 +1,33 @@
+<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 /2015-survey/ https://docs.google.com/forms/d/1j0LiFdZLjvfwoEyg5FML6z3sFKqV3Ar1mWReonYhatA/viewform
-- 
GitLab