Advertisement
Guest User

.htaccess

a guest
Sep 19th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.54 KB | None | 0 0
  1. <Files ~ "\.tpl$">
  2. Order allow,deny
  3. Deny from all
  4. </Files>
  5.  
  6. <ifModule mod_rewrite.c>
  7. RewriteEngine On
  8.  
  9. RewriteCond %{REQUEST_FILENAME} !-f
  10. RewriteCond %{REQUEST_FILENAME} !-d
  11. RewriteRule ^(.*)$ ./index.php?/$1 [L]
  12. </ifModule>
  13.  
  14. # Apache configuration file
  15. # httpd.apache.org/docs/2.2/mod/quickreference.html
  16.  
  17. # Note .htaccess files are an overhead, this logic should be in your Apache
  18. # config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
  19.  
  20. # Techniques in here adapted from all over, including:
  21. # Kroc Camen: camendesign.com/.htaccess
  22. # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
  23. # Sample .htaccess file of CMS MODx: modxcms.com
  24.  
  25.  
  26. # ----------------------------------------------------------------------
  27. # Better website experience for IE users
  28. # ----------------------------------------------------------------------
  29.  
  30. # Force the latest IE version, in various cases when it may fall back to IE7 mode
  31. # github.com/rails/rails/commit/123eb25#commitcomment-118920
  32. # Use ChromeFrame if it's installed for a better experience for the poor IE folk
  33.  
  34. <IfModule mod_headers.c>
  35. Header set X-UA-Compatible "IE=Edge,chrome=1"
  36. # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  37. <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
  38. Header unset X-UA-Compatible
  39. </FilesMatch>
  40. </IfModule>
  41.  
  42.  
  43. # ----------------------------------------------------------------------
  44. # Cross-domain AJAX requests
  45. # ----------------------------------------------------------------------
  46.  
  47. # Serve cross-domain Ajax requests, disabled by default.
  48. # enable-cors.org
  49. # code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
  50.  
  51. <IfModule mod_headers.c>
  52. Header set Access-Control-Allow-Origin "*"
  53. </IfModule>
  54.  
  55.  
  56. # ----------------------------------------------------------------------
  57. # CORS-enabled images (@crossorigin)
  58. # ----------------------------------------------------------------------
  59.  
  60. # Send CORS headers if browsers request them; enabled by default for images.
  61. # developer.mozilla.org/en/CORS_Enabled_Image
  62. # blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
  63. # hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
  64. # wiki.mozilla.org/Security/Reviews/crossoriginAttribute
  65.  
  66. <IfModule mod_setenvif.c>
  67. <IfModule mod_headers.c>
  68. # mod_headers, y u no match by Content-Type?!
  69. <FilesMatch "\.(gif|ico|jpe?g|png|svg|svgz|webp)$">
  70. SetEnvIf Origin ":" IS_CORS
  71. Header set Access-Control-Allow-Origin "*" env=IS_CORS
  72. </FilesMatch>
  73. </IfModule>
  74. </IfModule>
  75.  
  76.  
  77. # ----------------------------------------------------------------------
  78. # Webfont access
  79. # ----------------------------------------------------------------------
  80.  
  81. # Allow access from all domains for webfonts.
  82. # Alternatively you could only whitelist your
  83. # subdomains like "subdomain.example.com".
  84.  
  85. <IfModule mod_headers.c>
  86. <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
  87. Header set Access-Control-Allow-Origin "*"
  88. </FilesMatch>
  89. </IfModule>
  90.  
  91.  
  92. # ----------------------------------------------------------------------
  93. # Proper MIME type for all files
  94. # ----------------------------------------------------------------------
  95.  
  96. # JavaScript
  97. # Normalize to standard type (it's sniffed in IE anyways)
  98. # tools.ietf.org/html/rfc4329#section-7.2
  99. AddType application/javascript js jsonp
  100. AddType application/json json
  101.  
  102. # Audio
  103. AddType audio/mp4 m4a f4a f4b
  104. AddType audio/ogg oga ogg
  105.  
  106. # Video
  107. AddType video/mp4 mp4 m4v f4v f4p
  108. AddType video/ogg ogv
  109. AddType video/webm webm
  110. AddType video/x-flv flv
  111.  
  112. # SVG
  113. # Required for svg webfonts on iPad
  114. # twitter.com/FontSquirrel/status/14855840545
  115. AddType image/svg+xml svg svgz
  116. AddEncoding gzip svgz
  117.  
  118. # Webfonts
  119. AddType application/vnd.ms-fontobject eot
  120. AddType application/x-font-ttf ttf ttc
  121. AddType application/x-font-woff woff
  122. AddType font/opentype otf
  123.  
  124. # Assorted types
  125. AddType application/octet-stream safariextz
  126. AddType application/x-chrome-extension crx
  127. AddType application/x-opera-extension oex
  128. AddType application/x-shockwave-flash swf
  129. AddType application/x-web-app-manifest+json webapp
  130. AddType application/x-xpinstall xpi
  131. AddType application/xml rss atom xml rdf
  132. AddType image/webp webp
  133. AddType image/x-icon ico
  134. AddType text/cache-manifest appcache manifest
  135. AddType text/vtt vtt
  136. AddType text/x-component htc
  137. AddType text/x-vcard vcf
  138.  
  139.  
  140. # ----------------------------------------------------------------------
  141. # Allow concatenation from within specific js and css files
  142. # ----------------------------------------------------------------------
  143.  
  144. # e.g. Inside of script.combined.js you could have
  145. # <!--#include file="libs/jquery-1.5.0.min.js" -->
  146. # <!--#include file="plugins/jquery.idletimer.js" -->
  147. # and they would be included into this single file.
  148.  
  149. # This is not in use in the boilerplate as it stands. You may
  150. # choose to use this technique if you do not have a build process.
  151.  
  152. #<FilesMatch "\.combined\.js$">
  153. # Options +Includes
  154. # AddOutputFilterByType INCLUDES application/javascript application/json
  155. # SetOutputFilter INCLUDES
  156. #</FilesMatch>
  157.  
  158. #<FilesMatch "\.combined\.css$">
  159. # Options +Includes
  160. # AddOutputFilterByType INCLUDES text/css
  161. # SetOutputFilter INCLUDES
  162. #</FilesMatch>
  163.  
  164.  
  165. # ----------------------------------------------------------------------
  166. # Gzip compression
  167. # ----------------------------------------------------------------------
  168.  
  169. <IfModule mod_deflate.c>
  170.  
  171. # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  172. <IfModule mod_setenvif.c>
  173. <IfModule mod_headers.c>
  174. SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  175. RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  176. </IfModule>
  177. </IfModule>
  178.  
  179. # Compress all output labeled with one of the following MIME-types
  180. # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
  181. # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines as
  182. # `AddOutputFilterByType` is still in the core directives)
  183. <IfModule mod_filter.c>
  184. AddOutputFilterByType DEFLATE application/atom+xml \
  185. application/javascript \
  186. application/json \
  187. application/rss+xml \
  188. application/vnd.ms-fontobject \
  189. application/x-font-ttf \
  190. application/xhtml+xml \
  191. application/xml \
  192. font/opentype \
  193. image/svg+xml \
  194. image/x-icon \
  195. text/css \
  196. text/html \
  197. text/plain \
  198. text/x-component \
  199. text/xml
  200. </IfModule>
  201.  
  202. </IfModule>
  203.  
  204.  
  205. # ----------------------------------------------------------------------
  206. # Expires headers (for better cache control)
  207. # ----------------------------------------------------------------------
  208.  
  209. # These are pretty far-future expires headers.
  210. # They assume you control versioning with filename-based cache busting
  211. # Additionally, consider that outdated proxies may miscache
  212. # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
  213.  
  214. # If you don't use filenames to version, lower the CSS and JS to something like
  215. # "access plus 1 week".
  216.  
  217. <IfModule mod_expires.c>
  218. ExpiresActive on
  219.  
  220. # Perhaps better to whitelist expires rules? Perhaps.
  221. ExpiresDefault "access plus 1 month"
  222.  
  223. # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
  224. ExpiresByType text/cache-manifest "access plus 0 seconds"
  225.  
  226. # Your document html
  227. ExpiresByType text/html "access plus 0 seconds"
  228.  
  229. # Data
  230. ExpiresByType application/json "access plus 0 seconds"
  231. ExpiresByType application/xml "access plus 0 seconds"
  232. ExpiresByType text/xml "access plus 0 seconds"
  233.  
  234. # Feed
  235. ExpiresByType application/atom+xml "access plus 1 hour"
  236. ExpiresByType application/rss+xml "access plus 1 hour"
  237.  
  238. # Favicon (cannot be renamed)
  239. ExpiresByType image/x-icon "access plus 1 week"
  240.  
  241. # Media: images, video, audio
  242. ExpiresByType audio/ogg "access plus 1 month"
  243. ExpiresByType image/gif "access plus 1 month"
  244. ExpiresByType image/jpeg "access plus 1 month"
  245. ExpiresByType image/png "access plus 1 month"
  246. ExpiresByType video/mp4 "access plus 1 month"
  247. ExpiresByType video/ogg "access plus 1 month"
  248. ExpiresByType video/webm "access plus 1 month"
  249.  
  250. # HTC files (css3pie)
  251. ExpiresByType text/x-component "access plus 1 month"
  252.  
  253. # Webfonts
  254. ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  255. ExpiresByType application/x-font-ttf "access plus 1 month"
  256. ExpiresByType application/x-font-woff "access plus 1 month"
  257. ExpiresByType font/opentype "access plus 1 month"
  258. ExpiresByType image/svg+xml "access plus 1 month"
  259.  
  260. # CSS and JavaScript
  261. ExpiresByType application/javascript "access plus 1 year"
  262. ExpiresByType text/css "access plus 1 year"
  263.  
  264. </IfModule>
  265.  
  266.  
  267. # ----------------------------------------------------------------------
  268. # Prevent mobile network providers from modifying your site
  269. # ----------------------------------------------------------------------
  270.  
  271. # The following header prevents modification of your code over 3G on some
  272. # European providers.
  273. # This is the official 'bypass' suggested by O2 in the UK.
  274.  
  275. # <IfModule mod_headers.c>
  276. # Header set Cache-Control "no-transform"
  277. # </IfModule>
  278.  
  279.  
  280. # ----------------------------------------------------------------------
  281. # ETag removal
  282. # ----------------------------------------------------------------------
  283.  
  284. # FileETag None is not enough for every server.
  285. <IfModule mod_headers.c>
  286. Header unset ETag
  287. </IfModule>
  288.  
  289. # Since we're sending far-future expires, we don't need ETags for
  290. # static content.
  291. # developer.yahoo.com/performance/rules.html#etags
  292. FileETag None
  293.  
  294.  
  295. # ----------------------------------------------------------------------
  296. # Stop screen flicker in IE on CSS rollovers
  297. # ----------------------------------------------------------------------
  298.  
  299. # The following directives stop screen flicker in IE on CSS rollovers - in
  300. # combination with the "ExpiresByType" rules for images (see above).
  301.  
  302. # BrowserMatch "MSIE" brokenvary=1
  303. # BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
  304. # BrowserMatch "Opera" !brokenvary
  305. # SetEnvIf brokenvary 1 force-no-vary
  306.  
  307.  
  308. # ----------------------------------------------------------------------
  309. # Set Keep-Alive Header
  310. # ----------------------------------------------------------------------
  311.  
  312. # Keep-Alive allows the server to send multiple requests through one
  313. # TCP-connection. Be aware of possible disadvantages of this setting. Turn on
  314. # if you serve a lot of static content.
  315.  
  316. <IfModule mod_headers.c>
  317. Header set Connection Keep-Alive
  318. </IfModule>
  319.  
  320.  
  321. # ----------------------------------------------------------------------
  322. # Cookie setting from iframes
  323. # ----------------------------------------------------------------------
  324.  
  325. # Allow cookies to be set from iframes (for IE only)
  326. # If needed, specify a path or regex in the Location directive.
  327.  
  328. # <IfModule mod_headers.c>
  329. # Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
  330. # </IfModule>
  331.  
  332.  
  333. # ----------------------------------------------------------------------
  334. # Start rewrite engine
  335. # ----------------------------------------------------------------------
  336.  
  337. # Turning on the rewrite engine is necessary for the following rules and
  338. # features. FollowSymLinks must be enabled for this to work.
  339.  
  340. # Some cloud hosting services require RewriteBase to be set: goo.gl/HOcPN
  341. # If using the h5bp in a subdirectory, use `RewriteBase /foo` instead where
  342. # 'foo' is your directory.
  343.  
  344. # If your web host doesn't allow the FollowSymlinks option, you may need to
  345. # comment it out and use `Options +SymLinksIfOwnerMatch`, but be aware of the
  346. # performance impact: http://goo.gl/Mluzd
  347.  
  348. <IfModule mod_rewrite.c>
  349. Options +FollowSymlinks
  350. # Options +SymLinksIfOwnerMatch
  351. RewriteEngine On
  352. # RewriteBase /
  353. </IfModule>
  354.  
  355.  
  356. # ----------------------------------------------------------------------
  357. # Suppress or force the "www." at the beginning of URLs
  358. # ----------------------------------------------------------------------
  359.  
  360. # The same content should never be available under two different URLs -
  361. # especially not with and without "www." at the beginning, since this can cause
  362. # SEO problems (duplicate content). That's why you should choose one of the
  363. # alternatives and redirect the other one.
  364.  
  365. # By default option 1 (no "www.") is activated.
  366. # no-www.org/faq.php?q=class_b
  367.  
  368. # If you'd prefer to use option 2, just comment out all option 1 lines
  369. # and uncomment option 2.
  370.  
  371. # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
  372.  
  373. # ----------------------------------------------------------------------
  374.  
  375. # Option 1:
  376. # Rewrite "www.example.com -> example.com".
  377.  
  378. <IfModule mod_rewrite.c>
  379. RewriteCond %{HTTPS} !=on
  380. RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  381. RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
  382. </IfModule>
  383.  
  384. # ----------------------------------------------------------------------
  385.  
  386. # Option 2:
  387. # Rewrite "example.com -> www.example.com".
  388. # Be aware that the following rule might not be a good idea if you use "real"
  389. # subdomains for certain parts of your website.
  390.  
  391. # <IfModule mod_rewrite.c>
  392. # RewriteCond %{HTTPS} !=on
  393. # RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
  394. # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  395. # </IfModule>
  396.  
  397.  
  398. # ----------------------------------------------------------------------
  399. # Built-in filename-based cache busting
  400. # ----------------------------------------------------------------------
  401.  
  402. # If you're not using the build script to manage your filename version revving,
  403. # you might want to consider enabling this, which will route requests for
  404. # `/css/style.20110203.css` to `/css/style.css`.
  405.  
  406. # To understand why this is important and a better idea than all.css?v1231,
  407. # please refer to the bundled documentation about `.htaccess`.
  408.  
  409. # <IfModule mod_rewrite.c>
  410. # RewriteCond %{REQUEST_FILENAME} !-f
  411. # RewriteCond %{REQUEST_FILENAME} !-d
  412. # RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
  413. # </IfModule>
  414.  
  415.  
  416. # ----------------------------------------------------------------------
  417. # Prevent SSL cert warnings
  418. # ----------------------------------------------------------------------
  419.  
  420. # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
  421. # https://www.example.com when your cert only allows https://secure.example.com
  422.  
  423. # <IfModule mod_rewrite.c>
  424. # RewriteCond %{SERVER_PORT} !^443
  425. # RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L]
  426. # </IfModule>
  427.  
  428.  
  429. # ----------------------------------------------------------------------
  430. # Prevent 404 errors for non-existing redirected folders
  431. # ----------------------------------------------------------------------
  432.  
  433. # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the
  434. # same name does not exist.
  435. # webmasterworld.com/apache/3808792.htm
  436.  
  437. Options -MultiViews
  438.  
  439.  
  440. # ----------------------------------------------------------------------
  441. # Custom 404 page
  442. # ----------------------------------------------------------------------
  443.  
  444. # You can add custom pages to handle 500 or 403 pretty easily, if you like.
  445. # If you are hosting your site in subdirectory, adjust this accordingly
  446. # e.g. ErrorDocument 404 /subdir/404.html
  447. ErrorDocument 404 /error
  448.  
  449.  
  450. # ----------------------------------------------------------------------
  451. # UTF-8 encoding
  452. # ----------------------------------------------------------------------
  453.  
  454. # Use UTF-8 encoding for anything served text/plain or text/html
  455. AddDefaultCharset utf-8
  456.  
  457. # Force UTF-8 for a number of file formats
  458. AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
  459.  
  460.  
  461. # ----------------------------------------------------------------------
  462. # A little more security
  463. # ----------------------------------------------------------------------
  464.  
  465. # To avoid displaying the exact version number of Apache being used, add the
  466. # following to httpd.conf (it will not work in .htaccess):
  467. # ServerTokens Prod
  468.  
  469. # "-Indexes" will have Apache block users from browsing folders without a
  470. # default document Usually you should leave this activated, because you
  471. # shouldn't allow everybody to surf through every folder on your server (which
  472. # includes rather private places like CMS system folders).
  473. <IfModule mod_autoindex.c>
  474. Options -Indexes
  475. </IfModule>
  476.  
  477. # Block access to "hidden" directories or files whose names begin with a
  478. # period. This includes directories used by version control systems such as
  479. # Subversion or Git.
  480. <IfModule mod_rewrite.c>
  481. RewriteCond %{SCRIPT_FILENAME} -d [OR]
  482. RewriteCond %{SCRIPT_FILENAME} -f
  483. RewriteRule "(^|/)\." - [F]
  484. </IfModule>
  485.  
  486. # Block access to backup and source files. These files may be left by some
  487. # text/html editors and pose a great security danger, when anyone can access
  488. # them.
  489. <FilesMatch "(\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp)|~)$">
  490. Order allow,deny
  491. Deny from all
  492. Satisfy All
  493. </FilesMatch>
  494.  
  495. # If your server is not already configured as such, the following directive
  496. # should be uncommented in order to set PHP's register_globals option to OFF.
  497. # This closes a major security hole that is abused by most XSS (cross-site
  498. # scripting) attacks. For more information: http://php.net/register_globals
  499. #
  500. # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS:
  501. #
  502. # Your server does not allow PHP directives to be set via .htaccess. In that
  503. # case you must make this change in your php.ini file instead. If you are
  504. # using a commercial web host, contact the administrators for assistance in
  505. # doing this. Not all servers allow local php.ini files, and they should
  506. # include all PHP configurations (not just this one), or you will effectively
  507. # reset everything to PHP defaults. Consult www.php.net for more detailed
  508. # information about setting PHP directives.
  509.  
  510. # php_flag register_globals Off
  511.  
  512. # Rename session cookie to something else, than PHPSESSID
  513. # php_value session.name sid
  514.  
  515. # Disable magic quotes (This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.)
  516. # php_flag magic_quotes_gpc Off
  517.  
  518. # Do not show you are using PHP
  519. # Note: Move this line to php.ini since it won't work in .htaccess
  520. # php_flag expose_php Off
  521.  
  522. # Level of log detail - log all errors
  523. # php_value error_reporting -1
  524.  
  525. # Write errors to log file
  526. # php_flag log_errors On
  527.  
  528. # Do not display errors in browser (production - Off, development - On)
  529. # php_flag display_errors Off
  530.  
  531. # Do not display startup errors (production - Off, development - On)
  532. # php_flag display_startup_errors Off
  533.  
  534. # Format errors in plain text
  535. # Note: Leave this setting 'On' for xdebug's var_dump() output
  536. # php_flag html_errors Off
  537.  
  538. # Show multiple occurrence of error
  539. # php_flag ignore_repeated_errors Off
  540.  
  541. # Show same errors from different sources
  542. # php_flag ignore_repeated_source Off
  543.  
  544. # Size limit for error messages
  545. # php_value log_errors_max_len 1024
  546.  
  547. # Don't precede error with string (doesn't accept empty string, use whitespace if you need)
  548. # php_value error_prepend_string " "
  549.  
  550. # Don't prepend to error (doesn't accept empty string, use whitespace if you need)
  551. # php_value error_append_string " "
  552.  
  553. # Increase cookie security
  554. <IfModule mod_php5.c>
  555. php_value session.cookie_httponly true
  556. php_flag magic_quotes_gpc Off
  557. </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement