-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.htaccess
executable file
·253 lines (201 loc) · 8.8 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# this configuration sets the upload limit size for images
php_value upload_max_filesize 25M
php_value post_max_size 64M
php_value memory_limit 128M
php_value file_uploads On
# OPTIONS
Options +FollowSymLinks -Multiviews
# disable directory browsing
Options All -Indexes
# DEFAULT SERVER CONFIGURATIONS
ServerSignature Off
DefaultLanguage en-US
SetEnv TZ America/Indianapolis
SetEnv SERVER_ADMIN [email protected]
AddDefaultCharset UTF-8
# TYPE-CASTING
AddType video/x-flv .flv
AddType application/x-shockwave-flash .swf
AddType image/x-icon .ico
AddType application/x-httpd-php .html .htm
AddType application/x-httpd-php .objectCache
AddType application/vnd.adobe.air-application-installer-package+zip .air
# ERROR DOCUMENTS
ErrorDocument 404 /core/http-errors/404.php
ErrorDocument 400 /core/http-errors/error.php
ErrorDocument 401 /core/http-errors/error.php
ErrorDocument 403 /core/http-errors/error.php
ErrorDocument 405 /core/http-errors/error.php
ErrorDocument 406 /core/http-errors/error.php
ErrorDocument 409 /core/http-errors/error.php
ErrorDocument 413 /core/http-errors/error.php
ErrorDocument 414 /core/http-errors/error.php
ErrorDocument 500 /core/http-errors/error.php
ErrorDocument 501 /core/http-errors/error.php
# DIRECTORY INDEX
DirectoryIndex index.php index.htm index.html
# INI SET
php_value register_globals on
php_value auto_prepend_file /var/www/slawner.dns04.com/config/config.php
php_flag output_buffering on
# ENVIRONMENT VARIABLES
SetEnv APPLICATION_ENV development
SetEnv REQ_URI %{HTTP_HOST}
SetEnv REQUEST_FILENAME %{REQUEST_FILENAME}
SetEnv REQUEST_URI %{REQUEST_URI}
# DEFAULT CHARSET AND LANGUAGE
<FilesMatch "\.(htm|html|css|js|php|cfm)$">
AddDefaultCharset UTF-8
DefaultLanguage en-US
</FilesMatch>
# SECURE OBJECT CACHE FILES
<FilesMatch "\.(objectCache)$">
order allow,deny
deny from all
</FilesMatch>
# SECURE THE .HTACCESS FILE
<Files .htaccess>
order allow,deny
deny from all
</Files>
# SECURE THE .ini FILE
<Files .ini>
order allow,deny
deny from all
</Files>
#----------------------
# STATIC FILE CACHE
#----------------------
<IfModule mod_headers.c>
Header unset Pragma
FileETag None
Header unset ETag
#cache images/pdf docs for 10 days
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif)$">
Header set Cache-Control "max-age=864000, public, must-revalidate"
Header unset Last-Modified
</FilesMatch>
#cache html/htm/xml/txt diles for 2 days
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
</IfModule>
#----------------------
# STATIC FILE COMPRESSION
#----------------------
#<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
#</IfModule>
#----------------------
# REWITE ENGINE
#----------------------
RewriteEngine On
RewriteBase /
<IfModule mod_rewrite.c>
# Blocking request based on User-Agent Header
SetEnvIfNoCase ^User-Agent$ .*(craftbot|download|extract|stripper|sucker|ninja|clshttp|webspider|leacher|collector|grabber|webpictures) HTTP_SAFE_BADBOT
SetEnvIfNoCase ^User-Agent$ .*(libwww-perl|aesop_com_spiderman) HTTP_SAFE_BADBOT
Deny from env=HTTP_SAFE_BADBOT
# Remove trailing slash
# e.g. example.com/foo/ will redirect to example.com/foo
# - Skip all rewrites if the file or folder already exists
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
# - Otherwise, (if its not the admin section) clean the trailing slash
RewriteCond %{REQUEST_URI} !^(sp|fr|en)?/admin(/)?.*$
RewriteRule ^(.+)(/)$ /$1 [R=302,L,NC,QSA]
# REMOVE THE DIRECTORY INDEX PAGE FROM THE URL (index.php, index.htm, index.html, default.php, default.htm, default.php)
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^/index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
# PAGE REWRITE RULE:
RewriteRule ^pages/(.*)$ /core/page_viewer/viewer.php?path-url=$1&rq=%{REQUEST_URI}&%{QUERY_STRING} [NC,L]
# IMAGE TRACKING PIXEL REDIRECTION
RewriteRule ^trc.png$ /index.php?trackPixel=TRUE&path=%{REQUEST_URI}&lang=$1&%{QUERY_STRING} [NC,L]
# Mobile redirection.
# RewriteCond %{HTTP_USER_AGENT} (iPhone|ipad) [NC]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_URI} !^/mobile/.*$
# RewriteCond %{HTTP_COOKIE} !^.*mobiredir=1.*$
# RewriteRule .* /mobile/ [R=302,L]
# -----------------------------------
# ADMIN dispatcher redirection
# -----------------------------------
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# Remove images from the test....
RewriteCond %{REQUEST_URI} !^.*(\.gif|\.png|\.jpeg|\.jpg|\.css|\.js|\.ico|/404\.php)$
RewriteCond %{REQUEST_FILENAME} !^.*(\.gif|\.png|\.jpeg|\.jpg|\.css|\.js|\.ico|/404\.php)$
RewriteRule ^(sp|fr|en)?(/)?admin(/)?(.*)$ admin/index.php?lang=$1&mvc-path=$4&%{QUERY_STRING} [NC,L]
# -----------------------------------
# Main request dispatcher redirection
# -----------------------------------
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !^.*(\.gif|\.png|\.jpeg|\.jpg|\.css|\.js|\.ico|/404\.php)$
RewriteCond %{REQUEST_FILENAME} !^.*(\.gif|\.png|\.jpeg|\.jpg|\.css|\.js|\.ico|/404\.php)$
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI} !^.*(\.gif|\.png|\.jpg|\.jpeg|\.css|\.js|\.ico|/404\.php)$
RewriteCond %{REQUEST_FILENAME} !^.*(\.gif|\.png|\.jpg|\.jpeg|\.css|\.js|\.ico|/404\.php)$
#RewriteRule ^(sp|fr|en)?(.*)$ /index.php?path=$2&lang=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^(\/?sp|\/?fr|\/?en)?(.*)$ /index.php?path=$2&lang=$1&%{QUERY_STRING} [NC,L]
# Removed REQUEST_URI and REQUEST_FILENAME due to HUGE security risks
# RewriteRule ^(sp|fr|en)?(.*)$ /index.php?path=$2&lang=$1&%{QUERY_STRING}&fileName=%{REQUEST_FILENAME}&rq=%{REQUEST_URI} [NC,L]
# DEFAULT LANGUAGE REWRITE RULE
# RewriteCond %{SCRIPT_FILENAME} !-d
# RewriteRule ^(sp|fr|en)([/])?(.*) ?path=%{REQUEST_URI}&lang=$1&%{QUERY_STRING} [NC,L]
#----------------------------------------
# HACK PROOFING.
#----------------------------------------
# proc/self/environ? no way!
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
</ifModule>
# FILE COMPRESSION
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# COMPRESSION CACHEING
# ExpiresActive on
# ExpiresActive on
# ExpiresByType image/gif "access plus 1 month"
# ExpiresByType image/png "access plus 1 month"
# ExpiresByType image/jpg "access plus 1 month"
# ExpiresByType image/jpeg "access plus 1 month"
# ExpiresByType video/ogg "access plus 1 month"
# ExpiresByType audio/ogg "access plus 1 month"
# ExpiresByType video/mp4 "access plus 1 month"
# ExpiresByType video/webm "access plus 1 month"
# FORCE IE RENDERING MODE
# Header set X-UA-Compatible "IE=Edge"
# Remove rendering for non-endpoint files
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
# Header unset X-UA-Compatible
</FilesMatch>