-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.htaccess
78 lines (67 loc) · 3.55 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
#add handler that allows html, json, rdf, and xml to work dynamically as PHP
#https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
#https://httpd.apache.org/docs/current/mod/mod_mime.html#addhandler
#AddType application/x-httpd-php .html .json .rdf
AddHandler php5-script .html .rdf .json
<FilesMatch "^(sitemap)\.xml$">
AddHandler php5-script .xml
</FilesMatch>
#serve all resources labeled as 'text/html' or 'text/plain' with the media type 'charset' parameter set to 'UTF-8'
#https://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset
AddDefaultCharset utf-8
#serve the following file types with the media type 'charset' parameter set to 'UTF-8'
#https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset
<IfModule mod_mime.c>
AddCharset utf-8 .atom .bbaw .css .geojson .js .json .jsonld .manifest .rdf .rss .topojson .vtt .webapp .webmanifest .xloc .xml
</IfModule>
#serve correct media type (MIME type) for resources
#https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype
<Files "manifest.json">
AddType application/manifest+json .json
</Files>
<Files "opensearch.xml">
AddType application/opensearchdescription+xml .xml
</Files>
AddType application/atom+xml .atom
#normalize to standard type for javascript
#https://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript .js
AddType application/json .json
AddType application/ld+json .jsonld
AddType application/rdf+xml .rdf
AddType application/rss+xml .rss
AddType application/xml .xml
#remove the 'X-Powered-By' response header set by some frameworks and server-side languages
#security measure - its value contains information about them: name, version number, etc.
#http://httpd.apache.org/docs/current/mod/mod_headers.html
<IfModule mod_headers.c>
Header unset X-Powered-By
</IfModule>
#compress html, css, javascript, font, and miscellaneous resources
#https://httpd.apache.org/docs/current/mod/mod_deflate.html
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE "text/css" "text/html" "text/javascript" "text/plain" "text/xml" "application/x-javascript" "application/javascript" "application/json" "application/ld+json" "application/manifest+json" "application/rdf+xml" "application/rss+xml" "application/x-font-woff" "application/x-font-ttf" "application/vnd.ms-fontobject" "font/eot" "font/opentype" "font/otf" "font/ttf" "font/x-woff" "image/bmp" "image/jpeg" "image/svg+xml" "image/vnd.microsoft.icon" "image/x-icon"
</IfModule>
#rewrite rules for URLs and directory patterns
#https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteEngine
#https://httpd.apache.org/docs/current/mod/core.html#options
#https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
#https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions
<IfModule mod_rewrite.c>
RewriteEngine On
#check for 200 header, legitimate url
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
#change www.lib.montana.edu/linked-people/about.html?id=5 to www.lib.montana.edu/linked-people/about/5
RewriteBase /linked-people/
RewriteRule about/([0-9]+) about.html?id=$1 [L,QSA]
#change www.lib.montana.edu/people/about.php?id=5 to www.lib.montana.edu/people/5
#RewriteRule ^([0-9]+)$ about.php?id=$1 [QSA]
#RewriteRule ^([0-9]+)/$ about.php?id=$1 [L,QSA]
#remove need to have .html extension in filename
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [L,QSA]
#remove need to have .php extension in filename
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L,QSA]
</IfModule>