-
-
Save TigerWhite/f885cf56e50f48e13cf275008d00cece to your computer and use it in GitHub Desktop.
.htaccess for Apache 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .htaccess | |
| # | |
| # https://gist.github.com/897822 | |
| # Sokolov Innokenty, <[email protected]> | |
| # in php.ini: | |
| # disable_functions "exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source" | |
| DirectoryIndex index.php | |
| # 404 ошибка | |
| ErrorDocument 404 /404.php | |
| # Кодировка по-умолчанию | |
| AddDefaultCharset UTF-8 | |
| # Используем utf-8 для ниже написаных форматов | |
| AddCharset utf-8 .html .css .js .xml .json .rss | |
| # Убираем браузинг по директориям | |
| Options All -Indexes | |
| # Не обязательно всем рассказывать, что это Апач | |
| ServerSignature Off | |
| # disable display of startup errors | |
| php_flag display_startup_errors Off | |
| # disable display of all other errors | |
| php_flag display_errors On | |
| # disable html markup of errors | |
| php_flag html_errors Off | |
| # enable logging of errors | |
| php_flag log_errors on | |
| # disable ignoring of repeat errors | |
| php_flag ignore_repeated_errors off | |
| # disable ignoring of unique source errors | |
| php_flag ignore_repeated_source off | |
| # enable logging of php memory leaks | |
| php_flag report_memleaks on | |
| # preserve most recent error via php_errormsg | |
| php_flag track_errors on | |
| # specify path to php error log | |
| #php_value error_log /var/www/project/logs/php_errors.log | |
| # specify recording of all php errors | |
| php_value error_reporting -1 | |
| # disable max error string length | |
| php_value log_errors_max_len 0 | |
| # Максимальный размер загружаемых файлов | |
| php_value upload_max_filesize 20M | |
| php_value post_max_size 20M | |
| # upload time | |
| php_value max_input_time 180 | |
| # Security fix | |
| php_value register_globals off | |
| php_value enable_dl off | |
| php_value magic_quotes_gpc off | |
| php_value magic_quotes_runtime off | |
| php_value magic_quotes_sybase off | |
| # Точность | |
| php_value precision 12 | |
| # Session | |
| # 3 hours in seconds | |
| php_value session.gc_maxlifetime 10800 | |
| php_value session.name Q | |
| php_value session.cookie_httponly true | |
| # Не даем IE войти в режим совместимости с IE7, даже когда он сам этого хочет | |
| # github.com/rails/rails/commit/123eb25#commitcomment-118920 | |
| # Используем ChromeFrame, если он установлен, чтобы сделать жизнь бедных | |
| # пользователей IE немного лучше | |
| <IfModule mod_setenvif.c> | |
| <IfModule mod_headers.c> | |
| BrowserMatch MSIE ie | |
| Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie | |
| </IfModule> | |
| </IfModule> | |
| # Поскольку мы не отправляем X-UA-Compatible для браузеров отличных от IE | |
| # (чтобы сократить размер заголовка), | |
| # Нам нужно дать знать прокси-серверам об измененении контента на основе UA | |
| <IfModule mod_headers.c> | |
| # Кеш-контроль включается только когда включен модуль mod_headers, | |
| # так что нам необходимо его здесь объявить | |
| Header append Vary User-Agent | |
| </IfModule> | |
| # Аудио | |
| AddType audio/ogg oga ogg | |
| # Видео | |
| AddType video/ogg ogv | |
| AddType video/mp4 mp4 | |
| AddType video/webm webm | |
| # Правильный формат для svg. Необходимо для работы svg шрифтов в iPad Safari | |
| # twitter.com/FontSquirrel/status/14855840545 | |
| AddType image/svg+xml svg svgz | |
| AddEncoding gzip svgz | |
| # Веб-шрифты | |
| AddType application/vnd.ms-fontobject eot | |
| AddType font/truetype ttf | |
| AddType font/opentype otf | |
| AddType application/x-font-woff woff | |
| # Другие форматы | |
| AddType image/x-icon ico | |
| AddType image/webp webp | |
| AddType text/cache-manifest appcache manifest | |
| AddType text/x-component htc | |
| AddType application/x-chrome-extension crx | |
| AddType application/x-xpinstall xpi | |
| AddType application/octet-stream safariextz | |
| # gzip сжатие. | |
| <IfModule mod_deflate.c> | |
| # html, txt, css, js, json, xml, htc: | |
| AddOutputFilterByType DEFLATE text/html text/plain text/css application/json | |
| AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript | |
| AddOutputFilterByType DEFLATE text/xml application/xml text/x-component | |
| # веб-шрифты и svg: | |
| <FilesMatch "\.(ttf|otf|eot|svg)$" > | |
| SetOutputFilter DEFLATE | |
| </FilesMatch> | |
| </IfModule> | |
| <IfModule mod_expires.c> | |
| # Enable expirations. | |
| ExpiresActive On | |
| # Cache all files for 2 weeks after access (A) | |
| ExpiresDefault A1209600 | |
| <FilesMatch \.php$> | |
| ExpiresActive Off | |
| </FilesMatch> | |
| </IfModule> | |
| # VCS security fix | |
| <IfModule mod_rewrite.c> | |
| RewriteRule "(^|/)\." - [F] | |
| </IfModule> | |
| # Редирект www.domain.com -> domain.com | |
| <IfModule mod_rewrite.c> | |
| RewriteCond %{HTTPS} !=on | |
| RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] | |
| RewriteRule ^(.*)$ http://%1/$1 [R=301,L] | |
| </IfModule> | |
| # Редирект domain.com/foo -> domain.com/foo/ | |
| <IfModule mod_rewrite.c> | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ | |
| RewriteRule ^(.*)$ /$1/ [R=301,L] | |
| </IfModule> | |
| <IfModule mod_rewrite.c> | |
| RewriteEngine on | |
| RewriteBase / | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_URI} !=/favicon.ico | |
| RewriteRule .* index.php [L] | |
| </IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment