it will redirect any incomming traffic to www. to https: and non www.
remember to rename example,com to your website adres :-)
It will also add file caching speeding up things a lot.
Code: Select all
RewriteOptions inherit
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
FileETag none
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
Header set Connection keep-alive
# Set up 1 day caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A8640000
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<ifModule mod_deflate.c>
<filesMatch "\.(css|js|x?html?|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
## EXPIRES CACHING ##
<FilesMatch "\.(css|js)$">
Header set Cache-Control "max-age=1728000, public, must-revalidate"
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/x-font-ttf "access plus 6 month"
ExpiresByType font/ttf "access plus 6 month"
# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff "access plus 6 month"
ExpiresByType application/x-font-woff "access plus 6 month"
ExpiresByType font/woff "access plus 6 month"
# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 "access plus 6 month"
ExpiresByType font/woff2 "access plus 6 month"
ExpiresByType image/jpg "access 3 month"
ExpiresByType image/gif "access 3 month"
ExpiresByType image/jpg "access 3 month"
ExpiresByType image/jpeg "access 3 month"
ExpiresByType image/png "access 3 month"
ExpiresByType text/css "access 3 month"
ExpiresByType application/x-javascript "access plus 2 month"
ExpiresByType text/javascript "access plus 2 month"
ExpiresByType application/javascript "access plus 2 month"
ExpiresByType image/x-icon "access plus 6 month"
ExpiresByType image/icon "access plus 6 month"
ExpiresByType application/x-ico "access plus 6 month"
ExpiresByType application/ico "access plus 6 month"
ExpiresByType application/x-font-woff "access plus 1 year"
<filesMatch "\.(js)$">
Header set Cache-Control "max-age=2160000, private"
</filesMatch>
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
Header set Connection keep-alive
</FilesMatch>
</IfModule>
#<IfModule mod_headers.c>
#Header always set X-XSS-Protection "1; mode=block"
#Header set Content-Security-Policy "default-src 'self'"
#Header set Access-Control-Allow-Origin *
#Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS
Header set Permissions-Policy "microphone=()"
#Header always set Referrer-Policy "same-origin"
Header always set Content-Security-Policy "media-src 'self'"
Header always edit Set-Cookie ^(.*)$ $1;SameSite=Lax
#</IfModule>
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
#RewriteRule ^twenga.xml$ index.php?route=feed/twenga [L]
RewriteRule ^beslist.csv$ index.php?route=feed/beslist [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]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
### 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
# php_admin_value open_basedir none
<Files 403.shtml>
order allow,deny
allow from all
</Files>