Skip to content

Commit c088372

Browse files
committed
add default htaccess
1 parent 62f0b42 commit c088372

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
dist/**/*.*
55
!dist/**/*.html
66
!dist/**/*.php
7+
!dist/**/*.htaccess
78

89
### JetBrains ###
910
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
@@ -217,4 +218,4 @@ $RECYCLE.BIN/
217218
# Windows shortcuts
218219
*.lnk
219220

220-
# End of https://www.gitignore.io/api/node,macos,windows,jetbrains,sublimetext,visualstudiocode
221+
# End of https://www.gitignore.io/api/node,macos,windows,jetbrains,sublimetext,visualstudiocode

dist/disabled.htaccess

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
AddDefaultCharset UTF-8
3+
4+
# ----------------------------------------------------------------------
5+
# Rewrite
6+
# ----------------------------------------------------------------------
7+
RewriteEngine On
8+
9+
# redirect */index.(php|html) to just */
10+
RewriteCond %{THE_REQUEST} ^GET.*index\.(php|html) [NC]
11+
RewriteRule (.*?)index\.(php|html)/*(.*) /$1$2 [R=301,NE,L]
12+
13+
# remove trailing slash
14+
RewriteCond %{REQUEST_FILENAME} !-d
15+
RewriteRule ^(.*)/$ /$1 [L,R=301]
16+
17+
# remove .html extension (does not work with "remove .php extension", only use one of them)
18+
RewriteCond %{REQUEST_FILENAME} !-f
19+
RewriteRule ^([^\.]+)$ $1.html [NC,L]
20+
21+
# remove .php extension (does not work with "remove .html extension", only use one of them)
22+
# RewriteCond %{REQUEST_FILENAME} !-f
23+
# RewriteRule ^([^\.]+)$ $1.php [NC,L]
24+
25+
# reidrect HTTP to HTTPS
26+
# RewriteCond %{HTTPS} !on
27+
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
28+
29+
# ----------------------------------------------------------------------
30+
# Basic Headers
31+
# ----------------------------------------------------------------------
32+
<IfModule mod_headers.c>
33+
Header set X-Content-Type-Options: nosniff
34+
Header set X-XSS-Protection: "1; mode=block"
35+
Header set X-Frame-Options: SAMEORIGIN
36+
Header unset X-Powered-By
37+
38+
<FilesMatch ".(js|css|xml|gz|html|png|jpg|ttf)$">
39+
Header append Vary: Accept-Encoding
40+
</FilesMatch>
41+
42+
<FilesMatch "\.(ttf|otf|eot)$">
43+
Header set Access-Control-Allow-Origin "*"
44+
</FilesMatch>
45+
</IfModule>
46+
47+
# ----------------------------------------------------------------------
48+
# Expires headers (for better cache control)
49+
# ----------------------------------------------------------------------
50+
# One year for image files
51+
<filesMatch ".(jpg|jpeg|png|gif|ico|svg|ttf)$">
52+
Header set Cache-Control "max-age=31536000, public"
53+
</filesMatch>
54+
55+
# One month for css and js
56+
<filesMatch ".(css|js)$">
57+
Header set Cache-Control "max-age=31536000, public"
58+
</filesMatch>
59+
60+
# ----------------------------------------------------------------------
61+
# COMPRESS
62+
# ----------------------------------------------------------------------
63+
##GZIP DEFLATE
64+
<IfModule mod_mime.c>
65+
AddType application/x-javascript .js
66+
AddType text/css .css
67+
AddType image/svg+xml svg
68+
AddType image/svg+xml svgz
69+
</IfModule>
70+
<IfModule mod_deflate.c>
71+
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
72+
<IfModule mod_setenvif.c>
73+
BrowserMatch ^Mozilla/4 gzip-only-text/html
74+
BrowserMatch ^Mozilla/4\.0[678] no-gzip
75+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
76+
</IfModule>
77+
<IfModule mod_headers.c>
78+
Header append Vary User-Agent env=!dont-vary
79+
</IfModule>
80+
</IfModule>

0 commit comments

Comments
 (0)