Htaccess in Opencart 3.0.3.8
Posted: Tue Apr 12, 2022 5:04 pm
How comes this file is missing in the latest Opencart versions?
Does adding it cause caching issues?
Does adding it cause caching issues?
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Have you got your file browser set not to show hidden files?scottyboyyy wrote: ↑Tue Apr 12, 2022 5:04 pmHow comes this file is missing in the latest Opencart versions?
yes, you still need these rules. Besides the rules for OpenCart core, there are also rules for hosting - php parameters
Code: Select all
RewriteBase /
####COMMENT this makes no sense
RewriteCond %{SERVER_PORT} xx
####COMMENT I assume that this is inserted by your host for certification validation
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
####COMMENT I assume that this is inserted by your host for certification validation
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^/home/xxxxx/public_html/storage/(.*) index.php?route=error/not_found [L]
####COMMENT I assume that this is inserted by your host for certification validation
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
####COMMENT I assume that this is inserted by your host for certification validation
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
#For Leverage browser caching,
<IfModule mod_expires.c>
ExpiresActive On
####COMMENT add default no caching before the more specific definitions
ExpiresDefault A0
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
### X-Security Headers ###
# X-XSS-Protection & X-Frame-Options & X-Content-Type nosniff & Strict-Transport-Security security header
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options SAMEORIGIN
Header set X-Content-Type-Options nosniff
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
</IfModule>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
#force https:
####COMMENT suggest you put this at the very top
RewriteEngine On
####COMMENT suggest you put this BEFORE the SEO _ROUTE_ redirect above
RewriteCond %{HTTPS} off
####COMMENT never use HTTP_HOST for redirects unless you have multiple hosts and you are sure it contains one of YOUR hosts, use the same rule you have for non-www to www below instead
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#ENABLING HSTS:
####COMMENT you already set this above, differently
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
#Force www:
####COMMENT suggest you put this BEFORE the SEO _ROUTE_ redirect above
RewriteCond %{HTTP_HOST} ^mediasos.co.uk [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^(.*)$ https://www.mediasos.co.uk/$1 [L,R=301,NC]
Thanks by Mona, great advice.by mona wrote: ↑Sat May 20, 2023 6:45 pmComments marked by ####COMMENTCode: Select all
RewriteBase / ####COMMENT this makes no sense RewriteCond %{SERVER_PORT} xx ####COMMENT I assume that this is inserted by your host for certification validation RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L] ####COMMENT I assume that this is inserted by your host for certification validation RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L] RewriteRule ^/home/xxxxx/public_html/storage/(.*) index.php?route=error/not_found [L] ####COMMENT I assume that this is inserted by your host for certification validation RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteRule ^system/download/(.*) index.php?route=error/not_found [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) ####COMMENT I assume that this is inserted by your host for certification validation RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] #For Leverage browser caching, <IfModule mod_expires.c> ExpiresActive On ####COMMENT add default no caching before the more specific definitions ExpiresDefault A0 # Images ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/webp "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType image/x-icon "access plus 1 year" # Video ExpiresByType video/mp4 "access plus 1 year" # CSS, JavaScript ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" # Others ExpiresByType application/pdf "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month" </IfModule> ### X-Security Headers ### # X-XSS-Protection & X-Frame-Options & X-Content-Type nosniff & Strict-Transport-Security security header <IfModule mod_headers.c> Header set X-XSS-Protection "1; mode=block" Header always append X-Frame-Options SAMEORIGIN Header set X-Content-Type-Options nosniff Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" </IfModule> <Files 403.shtml> order allow,deny allow from all </Files> #force https: ####COMMENT suggest you put this at the very top RewriteEngine On ####COMMENT suggest you put this BEFORE the SEO _ROUTE_ redirect above RewriteCond %{HTTPS} off ####COMMENT never use HTTP_HOST for redirects unless you have multiple hosts and you are sure it contains one of YOUR hosts, use the same rule you have for non-www to www below instead RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] #ENABLING HSTS: ####COMMENT you already set this above, differently Header set Strict-Transport-Security "max-age=31536000" env=HTTPS #Force www: ####COMMENT suggest you put this BEFORE the SEO _ROUTE_ redirect above RewriteCond %{HTTP_HOST} ^mediasos.co.uk [NC] RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteRule ^(.*)$ https://www.mediasos.co.uk/$1 [L,R=301,NC]