Blog

Previous Next

HTACCESS - Optimized for Opencart

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

What is it? .htaccess is a configuration file for use on web servers running the Apache Web Server software.

.htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer.

Ie. Can be used for password protection, hotlinking prevention, error handling etc .htaccess works in the directory you place it. Some uses: Can be used to set:

1.Expire headers Expire Headers are added to tell the browser how often it has to fetch files afresh from the server based on a specific expiry data.

2.Cache Control Headers Tells the browser how long files should be cached before they should be loaded anew.

This is important to make sure it does not reload files too often.

3.gZip Compress files and make them easier to download by the browsers. Browsers decompress on the fly.

4.Deflate It’s a compression technique same as gzip. Some servers work with only gzip or deflate. Ifmodule checks if it’s enabled.

5.Re-Writing URLs. This is good for SEF URLs.

 

#Gzip
<ifmodule mod_deflate.c>
    AddOutputFilter DEFLATE js css
    AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html

    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
#End Gzip

## 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 text/html "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 1 month"
</IfModule>
## EXPIRES CACHING ##

# BEGIN Cache-Control Headers
<FilesMatch "\.(css|js|ico|pdf|jpg|jpeg|png|gif|html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=31536050"
</FilesMatch>
#
# <IfModule mod_headers.c>
# <FilesMatch "\\.(ico|jpg|jpeg|jpe?g|png|gif|swf|gz)$">
# Header set Cache-Control "max-age=2592000, public"
# </FilesMatch>
# <FilesMatch "\\.(css)$">
# Header set Cache-Control "max-age=2592000, public"
# </FilesMatch>
# <FilesMatch "\\.(js)$">
# Header set Cache-Control "max-age=2592000, private"
# </FilesMatch>
# <filesMatch "\\.(html|htm)$">
# Header set Cache-Control "max-age=7200, public"
# </filesMatch>
# # Disable caching for scripts and other dynamic files
# <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
# Header unset Cache-Control
# </FilesMatch>
# </IfModule>
# END Cache-Control Headers

# Gzip
<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>

# 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 Directory 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/storage/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]

### 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 received. 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

Tags: ,

About Me

Oops...Almost forgot to say something about me. But anyway, I'm that guy, yule Msee, who'll sort out your techie issue and hails from the land of milk and honey. Not forgetting the bitter herbs too.

This is what am best at. Feel free to ask something. 

Latest News

Latest Tweets

Search

Loading