These are minimum requirements needed so that OpenCart can be installed and work properly.
Web Server (Apache suggested)
PHP (at least 5.4)
Curl enabled
Database (MySQLi suggested)
I know this is the official installation suggestion of OpenCart, But based on the request of my boss, we still choose Nginx -Tengine 2.2.4 (2.3.2) as our HTTP server.
But when I can’t use the .htaccess file to make my module fully compatible, I want to know how to achieve my needs in Nginx -Tengine 2.2.4 (2.3.2), Can anyone advise on the .htaccess file I used before?
Thank you!
Our .htaccess file:
Code: Select all
php_value log_errors on
php_value error_reporting 32767
php_value error_log /home/user/public_html/error_log
#Added by Red from TWNOC 2019-04-11
RewriteEngine On
RewriteBase /
SetEnvIfNoCase User-Agent "SemrushBot" bots
SetEnvIfNoCase User-Agent "AhrefsBot" bots
Deny from env=bots
#End of added
# 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
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# 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 ^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)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# PREVENT SQL INJECTION IN QUERY STRING
RewriteCond %{REQUEST_FILENAME} !sql_attack_protection\.php
RewriteCond %{QUERY_STRING} information_schema
RewriteRule ^(.*?) /sql_attack_protection.php [R=301,L]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
### 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
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
#DeflateCompressionLevel 9
# Browser specific settings
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bOpera !no-gzip
# Setup custom deflate log
#DeflateFilterNote Input instream
#DeflateFilterNote Output outstream
#DeflateFilterNote Ratio ratio
#LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%)' deflate
# Example of log file
#CustomLog logs/deflate_log DEFLATE
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
############################################
## Add default Expires header
## developer.yahoo.com/performance/rules.html
<FilesMatch "\.(ico|pdf|flv|jpg|JPG|jpeg|png|gif|js|css|swf|woff|svg)$">
ExpiresDefault "access plus 1 year"
</FilesMatch>
</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>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteRule ^.* - [F,L]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www.pcstore.com.tw/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.pcstore.com.tw/$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
<Files "xmlrpc.php">
Order Allow,Deny
deny from all
</Files>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
Can anyone tell me? If anyone can tell me, I will be very grateful for this, Thank you in advance for your help!
Thank you!