From 7c51b255fb327d65401f712c4d6d4f07e92de889 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Tue, 24 Nov 2015 12:47:26 +0100 Subject: [PATCH] htaccess fixe --- .htaccess | 165 +++++++++++++----------------------------------------- 1 file changed, 38 insertions(+), 127 deletions(-) diff --git a/.htaccess b/.htaccess index 1f8d5991..3d1e1a97 100755 --- a/.htaccess +++ b/.htaccess @@ -3,7 +3,7 @@ # # Protect files and directories from prying eyes. - + Order allow,deny @@ -20,7 +20,7 @@ ErrorDocument 404 /index.php DirectoryIndex index.php index.html index.htm # Override PHP settings that cannot be changed at runtime. See -# sites/default/default.settings.php and drupal_initialize_variables() in +# sites/default/default.settings.php and drupal_environment_initialize() in # includes/bootstrap.inc for settings that can be changed at runtime. # PHP 5, Apache 1 and 2. @@ -56,6 +56,17 @@ DirectoryIndex index.php index.html index.htm RewriteEngine on + # Set "protossl" to "s" if we were accessed via https://. This is used later + # if you enable "www." stripping or enforcement, in order to ensure that + # you don't bounce between http and https. + RewriteRule ^ - [E=protossl] + RewriteCond %{HTTPS} on + RewriteRule ^ - [E=protossl:s] + + # Make sure Authorization HTTP header is available to PHP + # even when running as CGI or FastCGI. + RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + # Block access to "hidden" directories whose names begin with a period. This # includes directories used by version control systems such as Subversion or # Git to store control files. Files whose names begin with a period, as well @@ -71,23 +82,6 @@ DirectoryIndex index.php index.html index.htm # downloaded. RewriteRule "(^|/)\." - [F] - # redirect all materiau domains to materio.com - RewriteCond %{HTTPS} off - RewriteCond %{HTTP_HOST} ^basebeta\.materio\.com [OR] - RewriteCond %{HTTP_HOST} ^materio\.com [OR] - RewriteCond %{HTTP_HOST} ^www\.materio\.fr [OR] - RewriteCond %{HTTP_HOST} ^materio\.fr [OR] - RewriteCond %{HTTP_HOST} ^www\.materio\.net [OR] - RewriteCond %{HTTP_HOST} ^materio\.net [OR] - RewriteCond %{HTTP_HOST} ^www\.materio\.eu [OR] - RewriteCond %{HTTP_HOST} ^materio\.eu - RewriteRule ^ http://www.materio.com%{REQUEST_URI} [L,R=301] - - # SSL - # RewriteCond %{HTTPS} off [OR] - # RewriteCond %{HTTP_HOST} ^www.materio\.com* - # RewriteRule ^(.*)$ https://materio.com/$1 [L,R=301] - # If your site can be accessed both with and without the 'www.' prefix, you # can use one of the following settings to redirect users to your preferred # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option: @@ -95,14 +89,15 @@ DirectoryIndex index.php index.html index.htm # To redirect all users to access the site WITH the 'www.' prefix, # (http://example.com/... will be redirected to http://www.example.com/...) # uncomment the following: - # RewriteCond %{HTTP_HOST} !^www\. [NC] - # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] + RewriteCond %{HTTP_HOST} . + RewriteCond %{HTTP_HOST} !^www\. [NC] + RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # # To redirect all users to access the site WITHOUT the 'www.' prefix, # (http://www.example.com/... will be redirected to http://example.com/...) # uncomment the following: # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] - # RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301] + # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301] # Modify the RewriteBase if you are using Drupal in a subdirectory or in a # VirtualDocumentRoot and the rewrite rules are not working properly. @@ -121,22 +116,24 @@ DirectoryIndex index.php index.html index.htm RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] - ## local - # RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1 - ## maison quentin - # RewriteCond %{REMOTE_ADDR} !^86\.68\.188\.175 - ## materio - # RewriteCond %{REMOTE_ADDR} !^212\.198\.136\.215 - ## maison bach - # RewriteCond %{REMOTE_ADDR} !^82\.230\.62\.145 - # RewriteRule !maintenance http://www.materio.com/maintenance [L,R=302,E=nocache:1] + # CUSTOMS + # redirect all materiau domains to materio.com + # RewriteCond %{HTTPS} off + # RewriteCond %{HTTP_HOST} ^basebeta\.materio\.com [OR] + # RewriteCond %{HTTP_HOST} ^materio\.com [OR] + # RewriteCond %{HTTP_HOST} ^www\.materio\.fr [OR] + # RewriteCond %{HTTP_HOST} ^materio\.fr [OR] + # RewriteCond %{HTTP_HOST} ^www\.materio\.net [OR] + # RewriteCond %{HTTP_HOST} ^materio\.net [OR] + # RewriteCond %{HTTP_HOST} ^www\.materio\.eu [OR] + # RewriteCond %{HTTP_HOST} ^materio\.eu + # RewriteRule ^ http://www.materio.com%{REQUEST_URI} [L,R=301] + + # SSL + # RewriteCond %{HTTPS} off [OR] + # RewriteCond %{HTTP_HOST} ^www.materio\.com* + # RewriteRule ^(.*)$ https://materio.com/$1 [L,R=301] - ## http://mark.koli.ch/2010/12/set-cache-control-and-expires-headers-on-a-redirect-with-mod-rewrite.html - ## Set the response header if the "nocache" environment variable is set - ## in the RewriteRule above. - # Header always set Cache-Control "no-store, no-cache, must-revalidate" env=nocache - ## Set Expires too ... - # Header always set Expires "Thu, 01 Jan 1970 00:00:00 GMT" env=nocache # Rules to correctly serve gzip compressed CSS and JS files. @@ -165,94 +162,8 @@ DirectoryIndex index.php index.html index.htm - - -# FROM Html5 BoilerPlate 4.0 - -# ---------------------------------------------------------------------- -# Proper MIME type for all files -# ---------------------------------------------------------------------- - -# JavaScript -# Normalize to standard type (it's sniffed in IE anyways) -# tools.ietf.org/html/rfc4329#section-7.2 -AddType application/javascript js jsonp -AddType application/json json - -# Audio -AddType audio/ogg oga ogg -AddType audio/mp4 m4a f4a f4b - -# Video -AddType video/ogg ogv -AddType video/mp4 mp4 m4v f4v f4p -AddType video/webm webm -AddType video/x-flv flv - -# SVG -# Required for svg webfonts on iPad -# twitter.com/FontSquirrel/status/14855840545 -AddType image/svg+xml svg svgz -AddEncoding gzip svgz - -# Webfonts -AddType application/vnd.ms-fontobject eot -AddType application/x-font-ttf ttf ttc -AddType font/opentype otf -AddType application/x-font-woff woff - -# Assorted types -AddType image/x-icon ico -AddType image/webp webp -AddType text/cache-manifest appcache manifest -AddType text/x-component htc -AddType application/xml rss atom xml rdf -AddType application/x-chrome-extension crx -AddType application/x-opera-extension oex -AddType application/x-xpinstall xpi -AddType application/octet-stream safariextz -AddType application/x-web-app-manifest+json webapp -AddType text/x-vcard vcf -AddType application/x-shockwave-flash swf -AddType text/vtt vtt - - - -# ---------------------------------------------------------------------- -# UTF-8 encoding -# ---------------------------------------------------------------------- - -# Use UTF-8 encoding for anything served text/plain or text/html -AddDefaultCharset utf-8 - -# Force UTF-8 for a number of file formats -AddCharset utf-8 .atom .css .js .json .rss .vtt .xml - - -# ---------------------------------------------------------------------- -# A little more security -# ---------------------------------------------------------------------- - - -# Block access to "hidden" directories or files whose names begin with a -# period. This includes directories used by version control systems such as -# Subversion or Git. - - RewriteCond %{SCRIPT_FILENAME} -d [OR] - RewriteCond %{SCRIPT_FILENAME} -f - RewriteRule "(^|/)\." - [F] - - -# Block access to backup and source files. These files may be left by some -# text/html editors and pose a great security danger, when anyone can access -# them. - - Order allow,deny - Deny from all - Satisfy All - - -# Increase cookie security - - php_value session.cookie_httponly true +# Add headers to all responses. + + # Disable content sniffing, since it's an attack vector. + Header always set X-Content-Type-Options nosniff