Previous Next

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.


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

<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"

# 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"
# <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.*

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

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

# 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

Add a comment
Tags: ,
Wake up, Kill it, Repeat.

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
Take two businessmen, Kamau running an electroninc shop in nyamakima and patel running an autospare shop along kirinyaga road. Both men take their sons to JKUAT for a degree course. Patel's son commutes daily from parklands while kamau's son lives in a small rented bedsitter in juja.
Before joining college, Patel son used to spend the days at the auto-spare shop a routine he continues every sat whrn not going to college. Over the vacations, he even takes over the mamanagement. Kamau on the other side believes that nyamakima is not the place for his university going son so he should get a degree and get a better job.
The two young men graduates and goes seperate ways. Patel junior now takes over the running of the autospare shop. Kamau Jr hits the road, looking for a job. Two years and he gets a job as a bank teller, supermarket clerk etc, after six months and with meagre income, kamau son is frustrated and decides to go back for an MBA and improve his CV.

In the same period, patel jr has gained some management skills of running the shop with a workforce of five employees. In his interactions with fellow business men and trips to source business stocks in China and india, he meets an indian business man who is trying to market some softwares and computer accessories manufactured in India and Taiwan. He and another accomplice form a company and agree to distribute them. At first, the company is operated fro the backyard of the autoshop.
Both men are now 28, for patel jr, the man is now confident and experienced in making business deals. He approaches a few companies, does presentations and convinces them to take up his products.
By now, he has passed the autospare shop to his siblings and is now running a full fledged IT company.
For kamau jr, he has graduated with an MBA, is now driving a car on loan and is now looking for a better job. He ends up becoming an employee at Patels company as a supervisor.
Guys, that is where the real entrepreneurship classes start, and a foot-holding is all our youth requires. Don't wonder why our MBA degree holders were looking for internship at Tuskys and wonder no more how Indians are still ruling this business economy!
Add a comment
Tags: ,
Previous Next

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Good Code

Been long since I wrote about good practices. Good development practices. If you aint doing what I'll mention here,
you need to evaluate how you do stuff. I'm not the best adviser out there, but I know what I did and turned around my productivity. The things I'll advice you to do here, are the things I used not to do, inturn spending the whole night doing almost nothing.

I mean, spending the whole night for a bug not worth it.

Will expound on each.

1. Always have a local copy

Basically, have a copy of your project in your machine. The best way to have this is to clone it in your machine if you're developing from online.
I use lamp stack, so, I have a copy at www directory, which serves as a go-to for references incase of anything, and also for adding new stuff to the project.

2. Test Environment

This is an online copy just for tests. This is important for examining how the system behaves while hosted. This copy is located at the production environment or a system with production environment settings.
Remember, set it as a sub-domain. You don't want a client's project out there before launch.
I usually push my projects to heroku, or my domain.

3. Live Environment

This is now the live copy of the system. This is where the system sits after development. This is where it's gonna be. This needs to be guarded well, secured, tested well, no downtimes and all that.

This is usually vetoed by the client. S/he is the one to say where the system is going to sit.

Your work as a developer in this phase is just to deploy the system, and/or advice the client on the best hosting environment.

4. Daemon

This is run as a background process, rather than being under the direct control of an interactive user. At this point, have all logs up and running. Have a way of troubleshooting and/or backtracking errors that may arise while the system is running.

Did I say I was stuck with an issue and the person to assist me always asked me of logs? I didn't. I didn't have them. I hadn't setup any daemon service, logging and all that.

It was hard for him to help me out. I set up all this and called him. After seeing I've done that, he proposed a face-to-face meeting instead of skype calls. (guess he saw I was ready to learn)

It worked readers.

Some errors are generated from some upgrades which aren't compatible, or modules which have redundant functionalities.

With these kept in mind, you'll be a better person than you were yesterday.


Add a comment


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