AddDefaultCharset UTF-8
ErrorDocument 404 /404
ErrorDocument 401 /password.php
RewriteEngine on

#RewriteCond %{SERVER_PORT} !^443$
#RewriteCond %{REQUEST_URI} =/
#RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# Каталог товаров
RewriteRule ^catalog/([^/]+)/?$	index.php?module=ProductsView&category=$1 [L,QSA]
RewriteRule ^catalog/([^/]+)/([^/]+)/?$	index.php?module=ProductsView&category=$1&brand=$2 [L,QSA]

RewriteRule ^products/([^/]+)/?$	index.php?module=ProductView&product_url=$1 [L,QSA]
RewriteRule ^products/?$	index.php?module=ProductsView [L,QSA]

RewriteRule ^brands/([^/]+)/?$	index.php?module=ProductsView&brand=$1 [L,QSA]
RewriteRule ^brands/([^/]+)/page_([^/]+)/?$	index.php?module=ProductsView&brand=$1&page=$2 [L,QSA]

# Поиск товаров
RewriteRule ^search/([^/]+)/?$	index.php?module=ProductsView&keyword=$1 [L,QSA]
RewriteRule ^search/?$	index.php?module=ProductsView [L,QSA]

# Блог
RewriteRule ^blog/([^/]+)/?$	index.php?module=BlogView&url=$1 [L,QSA]
RewriteRule ^blog/?$	index.php?module=BlogView [L,QSA]

# Корзина и заказы
RewriteRule ^cart/?$	index.php?module=CartView   [L,QSA]
RewriteRule ^cart/([^/]+)/?$	index.php?module=CartView&add_variant=$1  [L,QSA]
RewriteRule ^cart/remove/([^/]+)/?$	index.php?module=CartView&delete_variant=$1  [L,QSA]
RewriteRule ^order/([^/]+)/?$	index.php?module=OrderView&url=$1  [L,QSA]
RewriteRule ^order/?$	index.php?module=OrderView  [L,QSA]

# Для пользователей
RewriteRule ^user/login/?$	index.php?module=LoginView  [L,QSA]
RewriteRule ^user/register/?$	index.php?module=RegisterView  [L,QSA]
RewriteRule ^user/logout/?$	index.php?module=LoginView&action=logout  [L,QSA]
RewriteRule ^user/password_remind/?$	index.php?module=LoginView&action=password_remind  [L,QSA]
RewriteRule ^user/password_remind/([0-9a-z]+)/?$	index.php?module=LoginView&action=password_remind&code=$1  [L,QSA]
RewriteRule ^user/?$	index.php?module=UserView  [L,QSA]

# Google sitemap
RewriteRule ^sitemap.xml?$	sitemap.php  [L,QSA]

# XML
RewriteRule ^yandex.xml?$	yandex.php  [L,QSA]

# feedback
RewriteRule ^contact/?$	index.php?module=FeedbackView  [L,QSA]

#downloads
RewriteRule ^order/([^/]+)/([^/]+)/?$	index.php?module=OrderView&url=$1&file=$2  [L,QSA]


# Статические страницы
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$	index.php?module=PageView&page_url=$1 [L,QSA]
RewriteRule ^/?$	index.php?module=MainView&page_url= [L,QSA]

# Ресайз картинок на лету
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^files/products/(.+) resize/resize.php?file=$1&token=%{QUERY_STRING}
#RewriteCond %{THE_REQUEST} ^GET\ (.*)files/products/(.*)\?([A-z0-9]*) 
#RewriteRule ^files/products/(.+) resize/resize.php?file=%2&token=%3 [L,NE]

# Статьи
RewriteRule ^article/([^/]+)/?$	index.php?module=ArticlesView&article_url=$1 [L,QSA]
RewriteRule ^articles/([^/]+)/?$	index.php?module=ArticlesView&category=$1 [L,QSA]
RewriteRule ^articles/?$	index.php?module=ArticlesView [L,QSA]

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
Header append Vary User-Agent
</IfModule>

# Webfonts                             
AddType application/vnd.ms-fontobject  eot
AddType application/x-font-ttf    ttf ttc
AddType font/opentype                  otf
AddType application/x-font-woff        woff

AddType     image/svg+xml              svg svgz 
AddEncoding gzip                       svgz
# AddType application/x-httpd-php .php .tpl  

#php_flag display_startup_errors off
#php_flag display_errors off
#php_flag html_errors off
#php_flag log_errors on
#php_flag ignore_repeated_errors off
#php_flag ignore_repeated_source off
#php_flag report_memleaks on
#php_flag track_errors on
#php_value docref_root 0
#php_value docref_ext 0
#php_value error_log /home/path/public_html/domain/PHP_errors.log
#php_value error_reporting -1
#php_value log_errors_max_len 0

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

Options +FollowSymLinks

RewriteCond %{HTTP_HOST} ^www.zion-dveri.by
RewriteRule ^(.*)$ https://zion-dveri.by/$1 [R=permanent,L]

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/css
  <IfModule mod_setenvif.c>
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  </IfModule>
</IfModule>

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
Header append Vary User-Agent
</IfModule>

# Webfonts                             
AddType application/vnd.ms-fontobject  eot
AddType application/x-font-ttf    ttf ttc
AddType font/opentype                  otf
AddType application/x-font-woff        woff

AddType     image/svg+xml              svg svgz 
AddEncoding gzip                       svgz
AddType application/x-httpd-php .php .tpl  


<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On 
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</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 handler ^cgi-script$
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>

# сжатие text, html, javascript, css, xml:
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>
 
# кеш браузера
<ifModule mod_expires.c>
ExpiresActive On
 
#по умолчанию кеш в 5 секунд
ExpiresDefault "access plus 1 days"
 
# Включаем кэширование изображений и флэш на месяц
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/jpeg "access plus 4 weeks"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 43829 minutes"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
 
# Включаем кэширование css, javascript и текстовых файлоф на одну неделю
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
 
# Включаем кэширование html и htm файлов на один день
ExpiresByType text/html "access plus 43200 seconds"
 
# Включаем кэширование xml файлов на десять минут
ExpiresByType application/xhtml+xml "access plus 600 seconds"
 
# Нестандартные шрифты сайта 
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</ifModule>
