AddDefaultCharset UTF-8
<IfModule mod_expires.c>
# FileETag MTime Size
ExpiresActive on
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
# html
ExpiresByType text/html "access plus 5 seconds"
# XML
ExpiresByType text/xml "access plus 5 seconds"
ExpiresByType application/xml "access plus 5 seconds"
# RSS
ExpiresByType application/rss+xml "access plus 1 hour"
# Favicon
ExpiresByType image/x-icon "access plus 1 month"
# Картинки
ExpiresByType image/gif "access plus 1 years"
ExpiresByType image/png "access plus 1 years"
ExpiresByType image/jpeg "access plus 1 years"
ExpiresByType image/jpg "access plus 1 years"
ExpiresByType image/ico "access plus 1 years"
# HTC файлы (например css3pie)
ExpiresByType text/x-component "access plus 1 years"
# Нестандартные шрифты сайта
ExpiresByType application/x-font-ttf "access plus 1 years"
ExpiresByType font/opentype "access plus 1 years"
ExpiresByType application/x-font-woff "access plus 1 years"
ExpiresByType image/svg+xml "access plus 1 years"
ExpiresByType application/vnd.ms-fontobject "access plus 1 years"
# CSS и javascript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType text/js "access plus 1 year"
</IfModule>
# Cache-Control браузера
<ifModule mod_headers.c>
Header unset ETag
FileETag None
Header set Connection Keep-Alive
Header append Vary: Accept-Encoding
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
FileETag None
</FilesMatch>
# 30 дней
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
# 30 дней
<filesMatch "\.(css|js)$">
Header set Cache-Control "max-age=2592000, public"
Header set Content-Encoding: gzip
</filesMatch>
# 30 дня
<filesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
# 30 день
<filesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=2592000, privat, must-revalidate"
</filesMatch>
</ifModule>
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json text/javascript application/javascript application/x-javascript text/x-js text/ecmascript application/ecmascript text/vbscript text/fluffscript text/xml application/xml text/x-component application/xhtml+xml application/rss+xml application/atom+xml image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
</IfModule>
<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 ^text\.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image\.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifmodule>
</IfModule>
# DirectoryIndex index.php
Options +Indexes
Options +FollowSymLinks
RewriteEngine On
ErrorDocument 404 /404.html
# Редиректы
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*)\.html(.+) [OR]
RewriteCond %{REQUEST_URI} ^(.*)\.htm$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)\.ht$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)\.h$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)\.$
RewriteRule ^(.*)\.(.*) $1.html [R=301,L]
RewriteRule ^page/([0-9]+)(/?)$ index.php?cstart=$1 [L]
# Сам пост
RewriteBase /
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*)\.(.*)$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6 [L]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*)\.(.*)$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*)\.(.*)$ engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)\.(.*)$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4 [L]
RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*)$ index.php?newsid=$4&news_page=$2&cstart=$3 [L]
RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+)-(.*)$ index.php?newsid=$3&news_page=$2 [L]
RewriteRule ^([^.]+)/print:page,([0-9]+),([0-9]+)-(.*)$ engine/print.php?news_page=$2&newsid=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)/([0-9]+)-(.*)$ index.php?newsid=$2 [L]
RewriteRule ^page,([0-9]+),([0-9]+),([0-9]+)-(.*)$ index.php?newsid=$3&news_page=$1&cstart=$2 [L]
RewriteRule ^page,([0-9]+),([0-9]+)-(.*)$ index.php?newsid=$2&news_page=$1 [L]
RewriteRule ^print:page,([0-9]+),([0-9]+)-(.*)$ engine/print.php?news_page=$1&newsid=$2 [L]
RewriteRule ^([0-9]+)-(.*)$ index.php?newsid=$1 [L]
# За день
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})(/?)+$ index.php?year=$1&month=$2&day=$3 [L]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)(/?)+$ index.php?year=$1&month=$2&day=$3&cstart=$4 [L]
# За весь месяц
RewriteRule ^([0-9]{4})/([0-9]{2})(/?)+$ index.php?year=$1&month=$2 [L]
RewriteRule ^([0-9]{4})/([0-9]{2})/page/([0-9]+)(/?)+$ index.php?year=$1&month=$2&cstart=$3 [L]
# Вывод за весь год
RewriteRule ^([0-9]{4})(/?)+$ index.php?year=$1 [L]
RewriteRule ^([0-9]{4})/page/([0-9]+)(/?)+$ index.php?year=$1&cstart=$2 [L]
# вывод отдельному тегу
RewriteRule ^tags/([^/]*)(/?)+$ index.php?do=tags&tag=$1 [L]
RewriteRule ^tags/([^/]*)/page/([0-9]+)(/?)+$ index.php?do=tags&tag=$1&cstart=$2 [L]
# поиск по доп полям
RewriteRule ^xfsearch/([^/]*)(/?)+$ index.php?do=xfsearch&xf=$1 [L]
RewriteRule ^xfsearch/([^/]*)/page/([0-9]+)(/?)+$ index.php?do=xfsearch&xf=$1&cstart=$2 [L]
# вывод для отдельного юзера
RewriteRule ^user/([^/]*)/rss.xml$ engine/rss.php?subaction=allnews&user=$1 [L]
RewriteRule ^user/([^/]*)(/?)+$ index.php?subaction=userinfo&user=$1 [L]
RewriteRule ^user/([^/]*)/page/([0-9]+)(/?)+$ index.php?subaction=userinfo&user=$1&cstart=$2 [L]
RewriteRule ^user/([^/]*)/news(/?)+$ index.php?subaction=allnews&user=$1 [L]
RewriteRule ^user/([^/]*)/news/page/([0-9]+)(/?)+$ index.php?subaction=allnews&user=$1&cstart=$2 [L]
RewriteRule ^user/([^/]*)/news/rss.xml(/?)+$ engine/rss.php?subaction=allnews&user=$1 [L]
# вывод всех последних новостей
RewriteRule ^lastnews(/?)+$ index.php?do=lastnews [L]
RewriteRule ^lastnews/page/([0-9]+)(/?)+$ index.php?do=lastnews&cstart=$1 [L]
# вывод в виде каталога
RewriteRule ^catalog/([^/]*)/rss.xml$ engine/rss.php?catalog=$1 [L]
RewriteRule ^catalog/([^/]*)(/?)+$ index.php?catalog=$1 [L]
RewriteRule ^catalog/([^/]*)/page/([0-9]+)(/?)+$ index.php?catalog=$1&cstart=$2 [L]
# вывод непрочитанных статей
RewriteRule ^newposts(/?)+$ index.php?subaction=newposts [L]
RewriteRule ^newposts/page/([0-9]+)(/?)+$ index.php?subaction=newposts&cstart=$1 [L]
# вывод избранных статей
RewriteRule ^favorites(/?)+$ index.php?do=favorites [L]
RewriteRule ^favorites/page/([0-9]+)(/?)+$ index.php?do=favorites&cstart=$1 [L]
RewriteRule ^rules.html$ index.php?do=rules [L]
RewriteRule ^statistics.html$ index.php?do=stats [L]
RewriteRule ^addnews.html$ index.php?do=addnews [L]
RewriteRule ^rss.xml$ engine/rss.php [L]
RewriteRule ^sitemap.xml$ uploads/sitemap.xml [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)/page/([0-9]+)(/?)+$ index.php?do=cat&category=$1&cstart=$2 [L]
RewriteRule ^([^.]+)/?$ index.php?do=cat&category=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)/rss.xml$ engine/rss.php?do=cat&category=$1 [L]
RewriteRule ^page,([0-9]+),([^/]+).html$ index.php?do=static&page=$2&news_page=$1&seourl=$2 [L]
RewriteRule ^print:([^/]+).html$ engine/print.php?do=static&page=$1&seourl=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+).html$ index.php?do=static&page=$1&seourl=$1 [L]
### Редиректы с site.ru/category/index.php на site.ru/category/ и др.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.*)index\.php$
RewriteRule ^(.*)index\.php$ $1 [R=301,L]
### Редиректы с index.php на сайт
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html)\ HTTP/
RewriteRule ^index\.* / [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Для тех кого достали левые юзеры и личеры
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yapro.ru [NC]
RewriteRule \.(jpg|jpeg|png|gif|ico|css|js)$ - [NC,F,L]