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