Advertisement
Guest User

Untitled

a guest
Jun 16th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.55 KB | None | 0 0
  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)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$">
  7. Order allow,deny
  8. </FilesMatch>
  9.  
  10. # Don't show directory listings for URLs which map to a directory.
  11. Options -Indexes
  12.  
  13. # Follow symbolic links in this directory.
  14. Options +FollowSymLinks
  15.  
  16. # Make Drupal handle any 404 errors.
  17. ErrorDocument 404 /index.php
  18.  
  19. # Set the default handler.
  20. DirectoryIndex index.php index.html index.htm
  21.  
  22. # Override PHP settings that cannot be changed at runtime. See
  23. # sites/default/default.settings.php and drupal_environment_initialize() in
  24. # includes/bootstrap.inc for settings that can be changed at runtime.
  25.  
  26. # PHP 5, Apache 1 and 2.
  27. <IfModule mod_php5.c>
  28. php_flag magic_quotes_gpc off
  29. php_flag magic_quotes_sybase off
  30. php_flag register_globals off
  31. php_flag session.auto_start off
  32. php_value mbstring.http_input pass
  33. php_value mbstring.http_output pass
  34. php_flag mbstring.encoding_translation off
  35. </IfModule>
  36.  
  37. # Requires mod_expires to be enabled.
  38. <IfModule mod_expires.c>
  39. # Enable expirations.
  40. ExpiresActive On
  41.  
  42. # Cache all files for 2 weeks after access (A).
  43. ExpiresDefault A1209600
  44.  
  45. <FilesMatch \.php$>
  46. # Do not allow PHP scripts to be cached unless they explicitly send cache
  47. # headers themselves. Otherwise all scripts would have to overwrite the
  48. # headers set by mod_expires if they want another caching behavior. This may
  49. # fail if an error occurs early in the bootstrap process, and it may cause
  50. # problems if a non-Drupal PHP file is installed in a subdirectory.
  51. ExpiresActive Off
  52. </FilesMatch>
  53. </IfModule>
  54.  
  55. # Various rewrite rules.
  56. <IfModule mod_rewrite.c>
  57.  
  58. RewriteEngine On
  59.  
  60. RewriteCond %{HTTP_REFERER} ^http://referingdomain\.com/ [NC]
  61. RewriteRule ^(.*) /index.php [R=301,L]
  62.  
  63. # Block access to "hidden" directories whose names begin with a period. This
  64. # includes directories used by version control systems such as Subversion or
  65. # Git to store control files. Files whose names begin with a period, as well
  66. # as the control files used by CVS, are protected by the FilesMatch directive
  67. # above.
  68. #
  69. # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
  70. # not possible to block access to entire directories from .htaccess, because
  71. # <DirectoryMatch> is not allowed here.
  72. #
  73. # If you do not have mod_rewrite installed, you should remove these
  74. # directories from your webroot or otherwise protect them from being
  75. # downloaded.
  76. RewriteRule "(^|/)\." - [F]
  77.  
  78. # If your site can be accessed both with and without the 'www.' prefix, you
  79. # can use one of the following settings to redirect users to your preferred
  80. # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  81. #
  82. # To redirect all users to access the site WITH the 'www.' prefix,
  83. # (http://example.com/... will be redirected to http://www.example.com/...)
  84. # uncomment the following:
  85. # RewriteCond %{HTTP_HOST} !^www\. [NC]
  86. # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  87. #
  88. # To redirect all users to access the site WITHOUT the 'www.' prefix,
  89. # (http://www.example.com/... will be redirected to http://example.com/...)
  90. # uncomment the following:
  91. RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  92. RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
  93.  
  94. # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  95. # VirtualDocumentRoot and the rewrite rules are not working properly.
  96. # For example if your site is at http://example.com/drupal uncomment and
  97. # modify the following line:
  98. # RewriteBase /drupal
  99. #
  100. # If your site is running in a VirtualDocumentRoot at http://example.com/,
  101. # uncomment the following line:
  102. # RewriteBase /
  103.  
  104. ### BOOST START ###
  105.  
  106. # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  107. RewriteRule .* - [E=boostpath:normal]
  108.  
  109. # Caching for anonymous users
  110. # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  111. RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  112. RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
  113. RewriteCond %{HTTPS} on [OR]
  114. RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  115. RewriteCond %{ENV:REDIRECT_STATUS} 200
  116. RewriteRule .* - [S=3]
  117.  
  118. # GZIP
  119. RewriteCond %{HTTP:Accept-encoding} !gzip
  120. RewriteRule .* - [S=1]
  121. RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  122. RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html,E=no-gzip:1]
  123.  
  124. # NORMAL
  125. RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  126. RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
  127.  
  128. ### BOOST END ###
  129.  
  130.  
  131. # Pass all requests not referring directly to files in the filesystem to
  132. # index.php. Clean URLs are handled in drupal_environment_initialize().
  133. RewriteCond %{REQUEST_FILENAME} !-f
  134. RewriteCond %{REQUEST_FILENAME} !-d
  135. RewriteCond %{REQUEST_URI} !=/favicon.ico
  136. RewriteRule ^ index.php [L]
  137.  
  138. # Rules to correctly serve gzip compressed CSS and JS files.
  139. # Requires both mod_rewrite and mod_headers to be enabled.
  140. <IfModule mod_headers.c>
  141. # Serve gzip compressed CSS files if they exist and the client accepts gzip.
  142. RewriteCond %{HTTP:Accept-encoding} gzip
  143. RewriteCond %{REQUEST_FILENAME}\.gz -s
  144. RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
  145.  
  146. # Serve gzip compressed JS files if they exist and the client accepts gzip.
  147. RewriteCond %{HTTP:Accept-encoding} gzip
  148. RewriteCond %{REQUEST_FILENAME}\.gz -s
  149. RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
  150.  
  151. # Serve correct content types, and prevent mod_deflate double gzip.
  152. RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
  153. RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
  154.  
  155. <FilesMatch "(\.js\.gz|\.css\.gz)$">
  156. # Serve correct encoding type.
  157. Header set Content-Encoding gzip
  158. # Force proxies to cache gzipped & non-gzipped css/js files separately.
  159. Header append Vary Accept-Encoding
  160. </FilesMatch>
  161. </IfModule>
  162. </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement