#dnwr_host cdn1.opencart.im cdn2.opencart.im
RewriteEngine on
ErrorDocument 404 /index.php

# SEO URL Settings
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X_FORWARDED_PROTO} !^https$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{QUERY_STRING} ^(.*)&?page=1$
RewriteRule ^(.*)/?$ /$1?%1%2 [R=301,L]

<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
</IfModule>

# Prevent Directoy listing
Options All -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
    Order deny,allow
    Deny from all
</FilesMatch>

# Заголовки HTTP для безопасности
<ifModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-Content-Type-Options "nosniff"
</ifModule>

# SEO URL Settings
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteRule ^image-smp/(.*) index.php?route=product/smp_image&name=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

# Add "gzip Encoding" to already gzipped files
AddType text/css .css .cssgz
AddType text/javascript .js .jsgz
AddEncoding x-gzip .cssgz .jsgz

# Enable Gzip into use 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      ^text\.*
    mod_gzip_item_include mime      ^application/x-javascript.*
    mod_gzip_item_include mime      ^application/x-font-woff.*
    mod_gzip_item_exclude mime      ^image\.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>

# Disable access to php ettor log file
<Files php_error.log>
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

# Cache-Control
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

# Optimization for Browser Caching 
FileETag MTime Size
<IfModule mod_expires.c>
    ExpiresActive on
    <filesmatch ".(jpg|jpeg|gif|png|ico|css|js|cssgz|jsgz)$">
        ExpiresDefault "access plus 1 year"
    </filesmatch>
    ExpiresDefault "access 7 days"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType text/javascript "access plus 1 year"
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType text/html "access plus 7 day"
    ExpiresByType text/x-javascript "access 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresByType application/x-shockwave-flash "access 1 year"
</IfModule>

#Compatible with old browsers
<IfModule mod_setenvif.c>
    BrowserMatch "MSIE" force-no-vary
    BrowserMatch "Mozilla/4.[0-9]{2}" force-no-vary
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

#max_execution_time это максимальное время работы скрипта, поставил побольше, чтобы сервер не вырубал работающий скрипт.
php_value max_execution_time 200

### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations

## INCREASE PAGE SPEED HTACCESS MODIFICATION ##
<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
<ifModule mod_headers.c>
    Header append Vary User-Agent
</ifModule>
## END INCREASE PAGE SPEED HTACCESS MODIFICATION

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
