forked from jasoncodes/jasoncodes.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.htaccess
More file actions
83 lines (67 loc) · 2.6 KB
/
.htaccess
File metadata and controls
83 lines (67 loc) · 2.6 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
---
RewriteEngine On
# no-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# redirect my name domain to my vanity domain
RewriteCond %{HTTP_HOST} ^jasonweathered\.com$ [NC]
RewriteRule ^(.*)$ http://jasoncodes.com/$1 [R=301,L]
# redirect /feed to FeedBurner
RewriteRule ^feed$ http://feeds.jasoncodes.com/jasoncodes [R=302,L]
# disable multiviews and directory listings
# we're going to use rewriting instead of MultiViews
Options -MultiViews -Indexes
DirectorySlash Off
# short post URLs
{% for post in site.posts %}{% if post.short %}redirect 301 /{{ post.short }} {{ site.url }}{{ post.id }}
{% endif %}{% endfor %}
# our post receive hook's URL is /_deploy
# this week we're using PHP to handle it (fake MultiViews)
RewriteRule _deploy$ %{REQUEST_URI}.php
# redirect away /index.html from URLs
RewriteCond %{ENV:REDIRECT_DONE} ^$
RewriteCond %{REQUEST_URI} (.*)/index(?:\.html?)?$
RewriteRule .* %1/ [R=301,L]
# redirect away .html from URLs
RewriteCond %{ENV:REDIRECT_DONE} ^$
RewriteCond %{REQUEST_URI} (.*).html$
RewriteRule .* %1 [R=301]
# redirect /foo/bar/ to /foo/bar (for /foo/bar/index.html)
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} (.*)
RewriteCond %1/index.html -f
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule .* %1 [R=301]
# interpret /foo/bar as /foo/bar/index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule .* %{REQUEST_URI}/index.html [E=DONE:1]
# interpret /foo/bar as /foo/bar.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule .* %{REQUEST_URI}.html [E=DONE:1]
# no caching on our text/html content (maybe later)
ExpiresActive On
ExpiresByType text/html "access"
# allow long caching of assets with cache busting
RewriteCond %{REQUEST_URI} (css|js|jpe?g|png|gif|ico)$ [NC]
RewriteCond %{QUERY_STRING} ^[0-9]+$
RewriteRule ^(.*)$ $1 [env=is_cacheable:true]
Header set Cache-Control "public, max-age=31536000" env=is_cacheable
# set content types for fonts and icons
AddType font/ttf ttf
AddType font/otf otf
AddType application/vnd.ms-fontobject eot
AddType image/vnd.microsoft.icon ico
# set our 404 handler
# we don't use "404.html" here as our rewrite rules from above apply
# (i.e. it would 301 to /404.html instead of returning 404)
ErrorDocument 404 /404
# we get a 403 from accessing directories without index files. This is effectively a 404 as well.
ErrorDocument 403 /404
# tell IE we want the best renderer available (Chrome Frame if possible)
<Files "*.html">
Header set X-UA-Compatible "IE=edge,chrome=1"
</Files>