/
htaccess.hyde
32 lines (24 loc) · 1.21 KB
/
htaccess.hyde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#adapted from http://andrewho.co.uk/weblog/clean-urls-on-jekyll-apache
#Options +FollowSymLinks
#The first step is to turn on mod_rewrite:
RewriteEngine On
#Create 404.html and let .htaccess know about it:
ErrorDocument 404 /404.html
#All resources should be accessed via the main domain name, not a subdomain:
RewriteCond %{HTTP_HOST} ^[^\.]+\.ontologicalwarfare\.com$ [NC]
RewriteRule ^(.*)$ http://ontologicalwarfare.com/$1 [R=301,L]
#Remove trailing slashes (note that mod_dir fiddles around with them so disable that behaviour here too):
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
Options -Indexes
DirectorySlash Off
#Hide the *.html files by redirecting all requests for foo.html to foo:
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /.+\.html\ HTTP
RewriteRule ^(.+)\.html$ http://%{HTTP_HOST}/$1 [R=301,L]
#If the client requests /foo but that doesn't exist, then try /foo.html:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^.+$ %{REQUEST_FILENAME}.html [L]
#Next, If the client requests /foo but that doesn't exist, then try /foo/index.html:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule ^.+$ %{REQUEST_FILENAME}/index.html [L]