-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.htaccess
136 lines (106 loc) · 3.76 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
DefaultLanguage en-US
AddDefaultCharset UTF-8
RewriteEngine On
#gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can't Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
#Caching
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
ExpiresDefault "access plus 1 month"
# Favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/svg "access plus 1 month"
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"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 month"
</IfModule>
# Remove ETags because they're apparently bad for performance
Header unset Pragma
FileETag None
Header unset ETag
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Redirect trailing slash to no trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Remove .php extension from pages
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
# Internally add .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+[^/])$ $1.php
# Remove .html extension from pages
RewriteCond %{THE_REQUEST} ^[A-Z]{4,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
# Internally add .html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+[^/])$ $1.html
# Remove .htm
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.htm [NC]
RewriteRule ^ %1 [R,L,NC]
# Internally add .htm
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.htm -f
RewriteRule ^(.+[^/])$ $1.htm
# Redirect 404s to root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]
# Redirect index to root
RewriteCond %{REQUEST_URI} index/? [NC]
RewriteRule . / [L,R=301]
# Force https and www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.([^.]+\.[^.]+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
# Force https and no www
# RewriteCond %{HTTPS} off [OR]
# RewriteCond %{HTTP_HOST} ^www\.([^.]+\.[^.]+)$ [NC]
# RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
# Force http and www
# RewriteCond %{HTTPS} on [OR]
# RewriteCond %{HTTP_HOST} !^www\.([^.]+\.[^.]+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
# Force http and no www
# RewriteCond %{HTTPS} on [OR]
# RewriteCond %{HTTP_HOST} ^www\.([^.]+\.[^.]+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
</IfModule>