Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. # Various rewrite rules.
  2. <IfModule mod_rewrite.c>
  3. RewriteEngine on
  4.  
  5. # Set "protossl" to "s" if we were accessed via https://. This is used later
  6. # if you enable "www." stripping or enforcement, in order to ensure that
  7. # you don't bounce between http and https.
  8. RewriteRule ^ - [E=protossl]
  9. RewriteCond %{HTTPS} on
  10. RewriteRule ^ - [E=protossl:s]
  11.  
  12. # Make sure Authorization HTTP header is available to PHP
  13. # even when running as CGI or FastCGI.
  14. RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  15.  
  16. # Block access to "hidden" directories whose names begin with a period. This
  17. # includes directories used by version control systems such as Subversion or
  18. # Git to store control files. Files whose names begin with a period, as well
  19. # as the control files used by CVS, are protected by the FilesMatch directive
  20. # above.
  21. #
  22. # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
  23. # not possible to block access to entire directories from .htaccess because
  24. # <DirectoryMatch> is not allowed here.
  25. #
  26. # If you do not have mod_rewrite installed, you should remove these
  27. # directories from your webroot or otherwise protect them from being
  28. # downloaded.
  29. RewriteRule "(^|/)\.(?!well-known)" - [F]
  30.  
  31. # If your site can be accessed both with and without the 'www.' prefix, you
  32. # can use one of the following settings to redirect users to your preferred
  33. # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  34. #
  35. # To redirect all users to access the site WITH the 'www.' prefix,
  36. # (http://example.com/foo will be redirected to http://www.example.com/foo)
  37. # uncomment the following:
  38. # RewriteCond %{HTTP_HOST} .
  39. # RewriteCond %{HTTP_HOST} !^www\. [NC]
  40. # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  41. #
  42. # To redirect all users to access the site WITHOUT the 'www.' prefix,
  43. # (http://www.example.com/foo will be redirected to http://example.com/foo)
  44. # uncomment the following:
  45. # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  46. # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
  47.  
  48. # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  49. # VirtualDocumentRoot and the rewrite rules are not working properly.
  50. # For example if your site is at http://example.com/drupal uncomment and
  51. # modify the following line:
  52. #RewriteBase /drupal
  53. #
  54. # If your site is running in a VirtualDocumentRoot at http://example.com/,
  55. # uncomment the following line:
  56. #RewriteBase /
  57.  
  58. # Redirect common PHP files to their new locations.
  59. RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]
  60. RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild.php)
  61. RewriteCond %{REQUEST_URI} !core
  62. RewriteRule ^ %1/core/%2 [L,QSA,R=301]
  63.  
  64. # Rewrite install.php during installation to see if mod_rewrite is working
  65. RewriteRule ^core/install.php core/install.php?rewrite=ok [QSA,L]
  66.  
  67. # Pass all requests not referring directly to files in the filesystem to
  68. # index.php.
  69. RewriteCond %{REQUEST_FILENAME} !-f
  70. RewriteCond %{REQUEST_FILENAME} !-d
  71. RewriteCond %{REQUEST_URI} !=/favicon.ico
  72. RewriteRule ^ index.php [L]
  73.  
  74. # For security reasons, deny access to other PHP files on public sites.
  75. # Note: The following URI conditions are not anchored at the start (^),
  76. # because Drupal may be located in a subdirectory. To further improve
  77. # security, you can replace '!/' with '!^/'.
  78. # Allow access to PHP files in /core (like authorize.php or install.php):
  79. RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
  80. # Allow access to test-specific PHP files:
  81. RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
  82. # Allow access to Statistics module's custom front controller.
  83. # Copy and adapt this rule to directly execute PHP files in contributed or
  84. # custom modules or to run another PHP application in the same directory.
  85. RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
  86. # Deny access to any other PHP files that do not match the rules above.
  87. # Specifically, disallow autoload.php from being served directly.
  88. RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
  89.  
  90. # Rules to correctly serve gzip compressed CSS and JS files.
  91. # Requires both mod_rewrite and mod_headers to be enabled.
  92. <IfModule mod_headers.c>
  93. # Serve gzip compressed CSS files if they exist and the client accepts gzip.
  94. RewriteCond %{HTTP:Accept-encoding} gzip
  95. RewriteCond %{REQUEST_FILENAME}\.gz -s
  96. RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
  97.  
  98. # Serve gzip compressed JS files if they exist and the client accepts gzip.
  99. RewriteCond %{HTTP:Accept-encoding} gzip
  100. RewriteCond %{REQUEST_FILENAME}\.gz -s
  101. RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
  102.  
  103. # Serve correct content types, and prevent mod_deflate double gzip.
  104. RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
  105. RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
  106.  
  107. <FilesMatch "(\.js\.gz|\.css\.gz)$">
  108. # Serve correct encoding type.
  109. Header set Content-Encoding gzip
  110. # Force proxies to cache gzipped & non-gzipped css/js files separately.
  111. Header append Vary Accept-Encoding
  112. </FilesMatch>
  113. </IfModule>
  114. </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement