-
Notifications
You must be signed in to change notification settings - Fork 15
/
.htaccess-TEMPLATE
58 lines (48 loc) · 1.95 KB
/
.htaccess-TEMPLATE
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
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
# 1 week cache
<filesMatch ".(ico|png|css|js)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
# These are used for a daily update of the class versions
# from the Data Warehouse.
<Files *.sh>
Order Allow,Deny
Deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
# FIXME: Set your own domain and path here
# Set central CourseRoad domain [no trailing slash]
SetEnvIf CR_HOST ^ CR_HOST=courseroad.mit.edu
# Set CourseRoad path [leading slash, no trailing slash]
SetEnvIf CR_PATH ^ CR_PATH=/
# Set pages which won't be redirected by force HTTPS or a different domain
SetEnvIf REQUEST_URI /output.php$ NOREDIRECT=1
# Force HTTPS and central CourseRoad domain
RewriteCond %{ENV:NOREDIRECT} !1 [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond expr "tolower(%{SERVER_NAME}) != tolower(%{ENV:CR_HOST})"
RewriteRule (.*) https://%{ENV:CR_HOST}%{REQUEST_URI} [R]
# Access to secure.php requires certificates
<Files secure.php>
AuthType SSLCert
Require valid-user
</Files>
# Uncomment the next line to use beta mode.
# SetEnvIf BETA_MODE ^$ BETA_MODE=1
# Deploy for beta testing, requiring users with a set cookie to still access
# the site. This isn't ideal, but allows beta testers to still test login
# functionality and the like.
RewriteCond %{ENV:BETA_MODE} 1 [NC]
RewriteCond %{HTTP_COOKIE} !beta=notquitesecurebutgoodenough [NC]
RewriteCond %{REQUEST_URI} !/503.php [NC]
RewriteRule .* %{ENV:CR_PATH}/503.php
# [url]/username --> [url]/index.php?hash=username
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ %{ENV:CR_PATH}/index.php?hash=$1
# Define ErrorDocuments
ErrorDocument 401 /index.php?triedlogin=1
ErrorDocument 403 /index.php?hash=error403
ErrorDocument 404 /index.php?hash=error404
ErrorDocument 500 /index.php?hash=error500