ave-cms/.htaccess

335 lines
13 KiB
ApacheConf
Raw Normal View History

2017-06-24 00:58:56 +03:00
###################### AVE.CMS_HTACCESS_BEGIN ##########################
# Options:
# -MultiViews: Turns off multiviews so it doesn't interfer with our rewrite rules
# -Indexes: Stop directory listings
# +FollowSymlinks: Let out rewrite rules work
Options -Indexes +FollowSymLinks
# ------------------------------------------------------------------------------
# | PHP Configuration |
# ------------------------------------------------------------------------------
php_value default_charset utf-8
2020-01-20 13:09:57 +03:00
#Отлючаем вывод ошибок
2017-06-24 00:58:56 +03:00
#php_value error_reporting E_NONE
2020-01-20 13:09:57 +03:00
# Этот параметр устанавливает максимальное время в секундах, позволяющее скрипту запускаться прежде, чем он завершается синтаксическим анализатором.
2017-06-24 00:58:56 +03:00
#php_value max_execution_time 300
2020-01-20 13:09:57 +03:00
# Максимальное время загрузки данных для скрипта, в том числе и файлов из формы
2017-06-24 00:58:56 +03:00
#php_value max_input_time 300
2020-01-20 13:09:57 +03:00
# Ограничивает максимальный объем данных, получаемых от пользователя методом POST
2017-06-24 00:58:56 +03:00
#php_value post_max_size 512M
2020-01-20 13:09:57 +03:00
# Устанавливает максимальный размер файла, который может быть получен методом POST (меньше, чем post_max_size)
2017-06-24 00:58:56 +03:00
#php_value upload_max_filesize 128M
2020-01-20 13:09:57 +03:00
# Максимальное кол-во загружаемых файлов
2017-06-24 00:58:56 +03:00
#php_value max_file_uploads 50
2020-01-20 13:09:57 +03:00
# Включаем у PHP короткие <?
2017-06-24 00:58:56 +03:00
#php_value short_open_tag On
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
php_flag register_globals off
2020-01-20 13:09:57 +03:00
2017-06-24 00:58:56 +03:00
# ------------------------------------------------------------------------------
# | CORS-enabled images |
# ------------------------------------------------------------------------------
# Send the CORS header for images when browsers request it.
# https://developer.mozilla.org/en-US/docs/HTML/CORS_Enabled_Image
# http://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
# http://hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch "\.(cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
# ------------------------------------------------------------------------------
# | Web fonts access |
# ------------------------------------------------------------------------------
# Allow access to web fonts from all domains.
<IfModule mod_headers.c>
<FilesMatch "\.(eot|otf|tt[cf]|woff)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
# ##############################################################################
# # INTERNET EXPLORER #
# ##############################################################################
# ------------------------------------------------------------------------------
# | Better website experience |
# ------------------------------------------------------------------------------
# Force Internet Explorer to render pages in the highest available mode
# in the various cases when it may not.
# http://hsivonen.iki.fi/doctype/ie-mode.pdf
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=edge"
# `mod_headers` cannot match based on the content-type, however, this
# header should be send only for HTML pages and not for the other resources
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>
# ##############################################################################
# # MIME TYPES AND ENCODING #
# ##############################################################################
# ------------------------------------------------------------------------------
# | Proper MIME types for all files |
# ------------------------------------------------------------------------------
<IfModule mod_mime.c>
# Audio
AddType audio/mp4 m4a f4a f4b
AddType audio/ogg oga ogg opus
# Data interchange
AddType application/json json map
AddType application/ld+json jsonld
# JavaScript
# Normalize to standard type.
# http://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js
# Video
AddType video/mp4 f4v f4p m4v mp4
AddType video/ogg ogv
AddType video/webm webm
AddType video/x-flv flv
# Web fonts
AddType application/font-woff woff
AddType application/vnd.ms-fontobject eot
# Browsers usually ignore the font MIME types and simply sniff the bytes
# to figure out the font type.
# http://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
# Chrome however, shows a warning if any other MIME types are used for
# the following fonts.
AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
# Make SVGZ fonts work on the iPad.
# https://twitter.com/FontSquirrel/status/14855840545
AddType image/svg+xml svgz
AddEncoding gzip svgz
# Other
AddType application/octet-stream safariextz
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-web-app-manifest+json webapp
AddType application/x-xpinstall xpi
AddType application/xml atom rdf rss xml
AddType image/webp webp
AddType image/x-icon cur
AddType text/cache-manifest appcache manifest
AddType text/vtt vtt
AddType text/x-component htc
AddType text/x-vcard vcf
</IfModule>
# ------------------------------------------------------------------------------
# | UTF-8 encoding |
# ------------------------------------------------------------------------------
# Use UTF-8 encoding for anything served as `text/html` or `text/plain`.
AddDefaultCharset utf-8
# Force UTF-8 for certain file formats.
<IfModule mod_mime.c>
AddCharset utf-8 .atom .css .js .json .jsonld .rss .vtt .webapp .xml
</IfModule>
# ------------------------------------------------------------------------------
# | Expires headers |
# ------------------------------------------------------------------------------
# The following expires headers are set pretty far in the future. If you
# don't control versioning with filename-based cache busting, consider
# lowering the cache time for resources such as style sheets and JavaScript
# files to something like one week.
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/ld+json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
# Favicon (cannot be renamed!) and cursor images
2020-01-20 13:09:57 +03:00
ExpiresByType image/x-icon "access plus 2 months"
2017-06-24 00:58:56 +03:00
# HTML components (HTCs)
2020-01-20 13:09:57 +03:00
ExpiresByType text/x-component "access plus 1 month"
2017-06-24 00:58:56 +03:00
# HTML
2020-01-20 13:09:57 +03:00
ExpiresByType text/html "access plus 0 seconds"
2017-06-24 00:58:56 +03:00
# JavaScript
ExpiresByType application/javascript "access plus 1 year"
2020-01-20 13:09:57 +03:00
ExpiresByType text/javascript "access plus 1 year"
2017-06-24 00:58:56 +03:00
# Manifest files
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Media
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# Web feeds
ExpiresByType application/atom+xml "access plus 1 hour"
2020-01-20 13:09:57 +03:00
ExpiresByType application/rss+xml "access plus 1 hour"
2017-06-24 00:58:56 +03:00
# Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
2020-01-20 13:09:57 +03:00
# Images
ExpiresByType image/gif "access plus 2 months"
ExpiresByType image/jpeg "access plus 2 months"
ExpiresByType image/x-icon "access plus 2 months"
ExpiresByType image/png "access plus 2 months"
2017-06-24 00:58:56 +03:00
</IfModule>
2020-01-20 13:09:57 +03:00
<FilesMatch "\.(class|config|fields|functions|inc|modules|lib|templates|tmp)$">
2017-06-24 00:58:56 +03:00
Order allow,deny
</FilesMatch>
2020-01-20 13:09:57 +03:00
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000, must-revalidate"
</FilesMatch>
2017-06-24 00:58:56 +03:00
<IfModule mod_security.c>
SecFilterScanPOST Off
</IfModule>
2017-09-21 09:50:14 +03:00
# ------------------------------------------------------------------------------
# | mod_deflate.c |
# ------------------------------------------------------------------------------
<IfModule mod_deflate.c>
<FilesMatch "\.(css|js|x?html?|php)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
2020-01-20 13:09:57 +03:00
# ------------------------------------------------------------------------------
# | mod_gzip.c |
# ------------------------------------------------------------------------------
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_include mime ^text/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_include handler ^cgi-script$
</ifModule>
2017-06-24 00:58:56 +03:00
# ------------------------------------------------------------------------------
# | Rewrite engine |
# ------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Заглушка для index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://%{HTTP_HOST}/ [R=301,L]
# Убираем слеш в конце
# RewriteCond %{HTTP_HOST} (.*)
# RewriteCond %{REQUEST_URI} /$ [NC]
# RewriteRule ^(.*)(/)$ $1 [L,R=301]
# Редирект с www.domain.com на domain.com
# RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
# RewriteRule (.*) http://%1/$1 [R=permanent,L]
# Редирект с domain.com на www.domain.com
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [QSA,L]
# RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
2020-01-20 13:09:57 +03:00
RewriteCond %{REQUEST_URI} !^/(class|config|fields|functions|inc|modules|lib|templates|tmp)/
2017-06-24 00:58:56 +03:00
# Файл robots.txt
RewriteCond %{REQUEST_URI} !^/robots\.txt$ [NC]
# Файл sitemap.xml
RewriteRule ^sitemap.xml$ inc/sitemap.php [QSA,L]
2018-04-19 19:11:58 +03:00
RewriteRule ^sitemap-([0-9]+).xml$ inc/sitemap.php?id=$1 [QSA,L]
2017-06-24 00:58:56 +03:00
#--start-ave-editor--#
#--end-ave-editor--#
# RSS
RewriteRule ^rss/rss-([0-9]+).xml$ inc/rss.php?id=$1 [QSA,L]
RewriteRule \.(ico)$ - [NC,L]
2017-09-21 09:50:14 +03:00
# If-Modified-Since
RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}]
RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]
2017-06-24 00:58:56 +03:00
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
</IfModule>
####################### AVE.CMS_HTACCESS_END ###########################