-
Notifications
You must be signed in to change notification settings - Fork 34
/
.htaccess
178 lines (147 loc) · 6.92 KB
/
.htaccess
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# NoNonsense Forum v26 © Copyright (CC-BY) Kroc Camen 2010-2015
# licenced under Creative Commons Attribution 3.0 <creativecommons.org/licenses/by/3.0/deed.en_GB>
# you may do whatever you want to this code as long as you give credit to Kroc Camen, <camendesign.com>
# some features of this file taken from HTML5 boilerplate <h5bp.com>,
# which took features from my website <camendesign.com> :)
ServerSignature Off
AddDefaultCharset utf-8
# this ‘feature’ (MultiViews) drove me absolutely insane!
# without this, Apache will give a 404 for a rewrite if a folder of the same name does not exist (e.g. “/blog/hello”)
# <webmasterworld.com/apache/3808792.htm>
Options -MultiViews -Indexes +FollowSymLinks
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
# mime types:
# --------------------------------------------------------------------------------------------------------------------------
# NNF doesn't use all of these by default, but custom themes might,
# which will save admins having to modify this file
<IfModule mod_mime.c>
# JavaScript
# normalize to standard type (it's sniffed in IE anyways)
# <tools.ietf.org/html/rfc4329#section-7.2>
AddType application/javascript js
# XML / RSS
AddType application/xml xml
AddType application/rss+xml rss
# SVG
# required for svg webfonts on iPad
# <twitter.com/FontSquirrel/status/14855840545>
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
# webfonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
# Assorted types
AddType image/x-icon ico
AddType image/webp webp
AddType application/x-shockwave-flash swf
AddCharset utf-8 .css .js .rss .xml
</IfModule>
<Files "index.xml">
# 'index.xml' (unlike 'sitemap.xml') is an RSS feed
ForceType application/rss+xml
</Files>
# compression:
# --------------------------------------------------------------------------------------------------------------------------
<IfModule mod_deflate.c>
# Force compression for mangled headers.
# http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule>
# caching:
# --------------------------------------------------------------------------------------------------------------------------
# these expires are reasonbly quick, to reflect the rapid nature of forums
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 day"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType text/css "access plus 1 day"
ExpiresByType application/javascript "access plus 1 day"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/png "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType application/x-font-ttf "access plus 1 week"
ExpiresByType font/opentype "access plus 1 week"
ExpiresByType application/x-font-woff "access plus 1 week"
ExpiresByType image/svg+xml "access plus 1 week"
ExpiresByType application/vnd.ms-fontobject "access plus 1 week"
</IfModule>
# `FileETag None` is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
# Since we're sending far-future expires, we don't need ETags for static content
# <developer.yahoo.com/performance/rules.html#etags>
FileETag None
# rewrite rules:
# --------------------------------------------------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
# NNF will display an error message if .htaccess is missing, or not enabled;
# we detect that by this environment variable failing to carry through
RewriteRule .* - [E=HTTP_HTACCESS:1]
# HTTP_AUTH workaround for CGI:
# <orangejuiceliberationfront.com/http-auth-with-php-in-cgi-mode-e-g-on-dreamhost/>
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# custom favicon?
RewriteCond %{DOCUMENT_ROOT}/favicon\.ico !-f
RewriteRule ^favicon\.ico$ favicon.default.ico [NC,L]
# custom apple-touch-icon?
RewriteCond %{DOCUMENT_ROOT}/apple-touch-icon\.png !-f
RewriteRule ^apple-touch-icon\.png$ apple-touch-icon.default.png [NC,L]
RewriteCond %{DOCUMENT_ROOT}/apple-touch-icon-precomposed\.png !-f
RewriteRule ^apple-touch-icon-precomposed\.png$ apple-touch-icon.default.png [NC,L]
# custom windows tile icon?
RewriteCond %{DOCUMENT_ROOT}/metro-tile\.png !-f
RewriteRule ^metro-tile\.png$ metro-tile.default.png [NC,L]
# don’t allow any access to '/users' (this is accessed purely from the PHP)
RewriteRule ^users/.*$ - [NC,F]
# don’t allow forum access to users / themes / lib folder
RewriteCond %{QUERY_STRING} path=(?:themes|users|lib) [NC]
RewriteRule ^ - [F]
# page numbers on the root forum
RewriteRule ^[:+](\d+)$ ?page=$1 [QSA,L]
# a thread
RewriteCond %{REQUEST_URI} ^(/(?:[^\./&]+/)*[_a-z0-9-]+)(?:[:+]\d+)?$
RewriteCond %{DOCUMENT_ROOT}%1.rss -f
RewriteRule ^((?:[^\./&]+/)*)([_a-z0-9-]+)(?:[:+](\d+))?$ thread.php?path=$1&file=$2&page=$3 [QSA,L]
# a sub-forum
RewriteCond %{REQUEST_URI} ^(/(?:[^\./&]+/)+)(?:[:+]\d+)?$
RewriteCond %{DOCUMENT_ROOT}%1 -d
RewriteRule ^((?:[^\./&]+/)+)(?:[:+](\d+))?$ index.php?path=$1&page=$2 [QSA,L]
</IfModule>