-
Notifications
You must be signed in to change notification settings - Fork 0
/
.htaccess
81 lines (67 loc) · 3.01 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
# Turn off MultiViews
Options +FollowSymLinks -MultiViews
# Directives to ensure that *.rdf and *.ttl files serve properly per context type
AddType application/rdf+xml .rdf
AddType text/turtle .ttl
# Rewrite engine setup
RewriteEngine On
RewriteBase /
# Upgrade all connections to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
# Deny access to a variety of directories/files
RewriteRule ^docs/*.*$ - [R=403]
RewriteRule ^ontology/*.*$ - [R=403]
RewriteRule ^src/*.*$ - [R=403]
RewriteRule ^venv/*.*$ - [R=403]
RewriteRule ^.git/*.*$ - [R=403]
RewriteRule ^.gitmodules$ - [R=403]
RewriteRule ^.gitignore$ - [R=403]
RewriteRule ^Makefile$ - [R=403]
# Redirect all assets that hit static
RewriteRule ^static/(.*)$ documentation/static/$1 [R=303,nc,L]
# Catch any non-rewritten investigations that aren't RESTful
# ... a temp solution for when apache fails to follow symlinks
RewriteRule ^(?!documentation/)([a-z0-9_-]+)?/static/(.*)$ documentation/static/$2 [R=303]
RewriteRule ^(?!documentation/)([a-z0-9_-]+)?/(.*)-(.*)$ documentation/$2-$3 [R=303]
# Catch all with a trailing slash.. send to the index of documentation
RewriteCond %{REQUEST_URI} !\.html [NC]
RewriteRule ^(.+)/$ %{DOCUMENT_ROOT}/documentation/index.html [L,R=303]
# Rewrite rule 3.1: to serve Turtle content is requested
RewriteCond %{REQUEST_URI} !\.ttl [NC]
RewriteCond %{HTTP_ACCEPT} text/turtle
RewriteRule ^uco/(.*)$ uco/$1.ttl [L,R=303]
# Rewrite rule 3.2: to serve RDF content is requested
RewriteCond %{REQUEST_URI} !\.rdf [NC]
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteRule ^uco/(.*)$ uco/$1.rdf [L,R=303]
# Rewrite directly to the rdf when ^uco/<target> isn't docs
RewriteCond %{REQUEST_URI} !^/documentation/static/ [NC]
RewriteCond %{REQUEST_URI} !\.rdf [NC]
RewriteCond %{REQUEST_URI} !\.ttl [NC]
RewriteCond %{REQUEST_URI} !\.html [NC]
RewriteCond %{HTTP_ACCEPT} text/html [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteRule ^uco/(.*)$ uco/$1.rdf [L,R=303]
# Rewrite rule: to serve HTML of some uco sub-dir
RewriteCond %{REQUEST_URI} !^/documentation/static/ [NC]
RewriteCond %{REQUEST_URI} !\.* [NC]
RewriteCond %{HTTP_ACCEPT} text/html [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteRule ^uco/(.*)/(.*)$ uco/$1/$2.html [L,R=303]
# Rewrite rule: serve based on user-agent
RewriteCond %{REQUEST_URI} !^/documentation/static/ [NC]
RewriteCond %{REQUEST_URI} !\.rdf [NC]
RewriteCond %{REQUEST_URI} !\.ttl [NC]
RewriteCond %{REQUEST_URI} !\.html [NC]
RewriteCond %{HTTP_ACCEPT} text/html [OR]
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*
RewriteRule ^uco/(.*)/(.*)$ uco/$1/$2.html [L,R=303]
# Rewrite rule: serve based on user-agent
RewriteCond %{REQUEST_URI} !\.rdf [NC]
RewriteCond %{HTTP_ACCEPT} application/rdf\+xml
RewriteCond %{HTTP_USER_AGENT} ^(.*)/(.*)$
RewriteRule ^uco/(.*)/(.*)$ uco/$1/$2.rdf [L,R=303]
# What if they just tried reaching the base website?
RewriteRule ^/?$ %{DOCUMENT_ROOT}/documentation/index.html [L,R=303]