From ab6a9d1aec3295029803b7736d3342cdbb2573e2 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Tue, 10 Sep 2013 11:19:44 +0200
Subject: [PATCH] add .htaccess for URL rewriting

---
 content/.htaccess | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 content/.htaccess

diff --git a/content/.htaccess b/content/.htaccess
new file mode 100644
index 0000000..cacc4ef
--- /dev/null
+++ b/content/.htaccess
@@ -0,0 +1,21 @@
+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]
-- 
GitLab