1
|
#
|
2
|
# Apache/PHP/Drupal settings:
|
3
|
#
|
4
|
|
5
|
# Protect files and directories from prying eyes.
|
6
|
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
|
7
|
<IfModule mod_authz_core.c>
|
8
|
Require all denied
|
9
|
</IfModule>
|
10
|
<IfModule !mod_authz_core.c>
|
11
|
Order allow,deny
|
12
|
</IfModule>
|
13
|
</FilesMatch>
|
14
|
|
15
|
# Don't show directory listings for URLs which map to a directory.
|
16
|
Options -Indexes
|
17
|
|
18
|
# Follow symbolic links in this directory.
|
19
|
Options +FollowSymLinks
|
20
|
|
21
|
# Make Drupal handle any 404 errors.
|
22
|
ErrorDocument 404 /index.php
|
23
|
|
24
|
# Set the default handler.
|
25
|
DirectoryIndex index.php index.html index.htm
|
26
|
|
27
|
# Override PHP settings that cannot be changed at runtime. See
|
28
|
# sites/default/default.settings.php and drupal_environment_initialize() in
|
29
|
# includes/bootstrap.inc for settings that can be changed at runtime.
|
30
|
|
31
|
# PHP 5, Apache 1 and 2.
|
32
|
<IfModule mod_php5.c>
|
33
|
php_flag magic_quotes_gpc off
|
34
|
php_flag magic_quotes_sybase off
|
35
|
php_flag register_globals off
|
36
|
php_flag session.auto_start off
|
37
|
php_value mbstring.http_input pass
|
38
|
php_value mbstring.http_output pass
|
39
|
php_flag mbstring.encoding_translation off
|
40
|
</IfModule>
|
41
|
|
42
|
# Requires mod_expires to be enabled.
|
43
|
<IfModule mod_expires.c>
|
44
|
# Enable expirations.
|
45
|
ExpiresActive On
|
46
|
|
47
|
# Cache all files for 2 weeks after access (A).
|
48
|
ExpiresDefault A1209600
|
49
|
|
50
|
<FilesMatch \.php$>
|
51
|
# Do not allow PHP scripts to be cached unless they explicitly send cache
|
52
|
# headers themselves. Otherwise all scripts would have to overwrite the
|
53
|
# headers set by mod_expires if they want another caching behavior. This may
|
54
|
# fail if an error occurs early in the bootstrap process, and it may cause
|
55
|
# problems if a non-Drupal PHP file is installed in a subdirectory.
|
56
|
ExpiresActive Off
|
57
|
</FilesMatch>
|
58
|
</IfModule>
|
59
|
|
60
|
# Various rewrite rules.
|
61
|
<IfModule mod_rewrite.c>
|
62
|
RewriteEngine on
|
63
|
|
64
|
# Set "protossl" to "s" if we were accessed via https://. This is used later
|
65
|
# if you enable "www." stripping or enforcement, in order to ensure that
|
66
|
# you don't bounce between http and https.
|
67
|
RewriteRule ^ - [E=protossl]
|
68
|
RewriteCond %{HTTPS} on
|
69
|
RewriteRule ^ - [E=protossl:s]
|
70
|
|
71
|
# Make sure Authorization HTTP header is available to PHP
|
72
|
# even when running as CGI or FastCGI.
|
73
|
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
74
|
|
75
|
# Block access to "hidden" directories whose names begin with a period. This
|
76
|
# includes directories used by version control systems such as Subversion or
|
77
|
# Git to store control files. Files whose names begin with a period, as well
|
78
|
# as the control files used by CVS, are protected by the FilesMatch directive
|
79
|
# above.
|
80
|
#
|
81
|
# NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
|
82
|
# not possible to block access to entire directories from .htaccess, because
|
83
|
# <DirectoryMatch> is not allowed here.
|
84
|
#
|
85
|
# If you do not have mod_rewrite installed, you should remove these
|
86
|
# directories from your webroot or otherwise protect them from being
|
87
|
# downloaded.
|
88
|
RewriteRule "/\.|^\.(?!well-known/)" - [F]
|
89
|
|
90
|
# If your site can be accessed both with and without the 'www.' prefix, you
|
91
|
# can use one of the following settings to redirect users to your preferred
|
92
|
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
|
93
|
#
|
94
|
# To redirect all users to access the site WITH the 'www.' prefix,
|
95
|
# (http://example.com/... will be redirected to http://www.example.com/...)
|
96
|
# uncomment the following:
|
97
|
# RewriteCond %{HTTP_HOST} .
|
98
|
# RewriteCond %{HTTP_HOST} !^www\. [NC]
|
99
|
# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
100
|
#
|
101
|
# To redirect all users to access the site WITHOUT the 'www.' prefix,
|
102
|
# (http://www.example.com/... will be redirected to http://example.com/...)
|
103
|
# uncomment the following:
|
104
|
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
105
|
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
|
106
|
|
107
|
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
|
108
|
# VirtualDocumentRoot and the rewrite rules are not working properly.
|
109
|
# For example if your site is at http://example.com/drupal uncomment and
|
110
|
# modify the following line:
|
111
|
# RewriteBase /drupal
|
112
|
#
|
113
|
# If your site is running in a VirtualDocumentRoot at http://example.com/,
|
114
|
# uncomment the following line:
|
115
|
# RewriteBase /
|
116
|
|
117
|
# Pass all requests not referring directly to files in the filesystem to
|
118
|
# index.php. Clean URLs are handled in drupal_environment_initialize().
|
119
|
RewriteCond %{REQUEST_FILENAME} !-f
|
120
|
RewriteCond %{REQUEST_FILENAME} !-d
|
121
|
RewriteCond %{REQUEST_URI} !=/favicon.ico
|
122
|
RewriteRule ^ index.php [L]
|
123
|
|
124
|
# Rules to correctly serve gzip compressed CSS and JS files.
|
125
|
# Requires both mod_rewrite and mod_headers to be enabled.
|
126
|
<IfModule mod_headers.c>
|
127
|
# Serve gzip compressed CSS files if they exist and the client accepts gzip.
|
128
|
RewriteCond %{HTTP:Accept-encoding} gzip
|
129
|
RewriteCond %{REQUEST_FILENAME}\.gz -s
|
130
|
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
|
131
|
|
132
|
# Serve gzip compressed JS files if they exist and the client accepts gzip.
|
133
|
RewriteCond %{HTTP:Accept-encoding} gzip
|
134
|
RewriteCond %{REQUEST_FILENAME}\.gz -s
|
135
|
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
|
136
|
|
137
|
# Serve correct content types, and prevent mod_deflate double gzip.
|
138
|
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
|
139
|
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
|
140
|
|
141
|
<FilesMatch "(\.js\.gz|\.css\.gz)$">
|
142
|
# Serve correct encoding type.
|
143
|
Header set Content-Encoding gzip
|
144
|
# Force proxies to cache gzipped & non-gzipped css/js files separately.
|
145
|
Header append Vary Accept-Encoding
|
146
|
</FilesMatch>
|
147
|
</IfModule>
|
148
|
</IfModule>
|
149
|
|
150
|
# Add headers to all responses.
|
151
|
<IfModule mod_headers.c>
|
152
|
# Disable content sniffing, since it's an attack vector.
|
153
|
Header always set X-Content-Type-Options nosniff
|
154
|
</IfModule>
|