Speed Up Your CS-Cart eCommerce Website - .htaccess - Step 5

Hello All,

Quick reminder:

The most important step is Gzip as shown in Step 1

The second important step is SmartOptimizer as explained in Step 2

And now, the most difficult to build and test, is the .htaccess.

I bypass minor steps such as Step 4 with so few followers. In fact, I understand you: This Step 4 is too difficult.

So, this step 5 is a “Copy and Paste” code. I can’t do easier!

So, I shortcut my promise to delay the publishing of this third most important step to boost your CS-Cart website.

Why publish it now?

The Christmas season will soon beginning, so, it’s now time to have a full power CS-Cart website.

Remember, I worked and tested for 22 hours non-stop to find this (nearly perfect for me) “.htaccess”. With this .htaccess added to Steps 1 & 2, your website would go up to Yslow! result to ~88, and a PageSpeed result to ~85.

In practice, to get the 2 to 5 last points to get Grade A are hidden in minors steps. However, I will NOT give you, because, they are too difficult to acquire, and are time consuming.

[SIZE=“3”]Therefore, I wish you a merry Christmas![/SIZE]

DirectoryIndex index.html index.php<br />
<br />
<IfModule mod_rewrite.c><br />
RewriteEngine on<br />
# Some hostings require RewriteBase to be uncommented<br />
# Example:<br />
# Your store url is http://www.yourcompany.com/store/cscart<br />
# So "RewriteBase" should be:<br />
# RewriteBase /store/cscart <br />
# RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . index.php?sef_rewrite=1 [L,QSA]<br />
RewriteRule ^(.*\.(js|css))$ smartoptimizer/?$1<br />
</IfModule>	<br />
	<br />
	<IfModule !mod_expires.c><br />
		RewriteCond %{REQUEST_FILENAME} -f<br />
		RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt))$ smartoptimizer/?$1<br />
	</IfModule><br />
<br />
<IfModule mod_expires.c><br />
	<FilesMatch "\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt)$"><br />
		ExpiresActive On<br />
		ExpiresDefault "access plus 10 years"<br />
	</FilesMatch><br />
</IfModule><br />
<br />
<IfModule mod_headers.c><br />
 <FilesMatch \.(css|js)$><br />
 Header append Vary User-Agent<br />
 Header append Vary Accept-Encoding<br />
 Header append Cache-Control private<br />
 </FilesMatch><br />
 <FilesMatch \.(bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt|eot|ttf|otf|svg)$><br />
 Header append Cache-Control public<br />
 </FilesMatch><br />
 <FilesMatch \.(js|css|bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt)$><br />
Header unset ETag<br />
FileETag None<br />
 </FilesMatch><br />
</IfModule><br />
<br />
# Turn on Expires and set default to 0<br />
<IfModule mod_expires.c><br />
 ExpiresActive On<br />
 <FilesMatch \.css$><br />
 ExpiresDefault "access plus 10 years"<br />
 </FilesMatch><br />
 ExpiresByType text/css A315360000<br />
 <FilesMatch \.js$><br />
 ExpiresDefault "access plus 10 years"<br />
 </FilesMatch><br />
 ExpiresByType text/javascript A315360000<br />
 ExpiresByType application/javascript A315360000<br />
 ExpiresByType application/x-javascript A315360000<br />
 ExpiresByType text/x-js A315360000<br />
 ExpiresByType text/ecmascript A315360000<br />
 ExpiresByType application/ecmascript A315360000<br />
 ExpiresByType text/vbscript A315360000<br />
 ExpiresByType text/fluffscript A315360000<br />
 <FilesMatch \.(bmp|png|gif|jpe?g|ico)$><br />
 ExpiresDefault "access plus 10 years"<br />
 </FilesMatch><br />
 ExpiresByType image/gif A315360000<br />
 ExpiresByType image/png A315360000<br />
 ExpiresByType image/jpeg A315360000<br />
 ExpiresByType image/x-icon A315360000<br />
 ExpiresByType image/bmp A315360000<br />
 <FilesMatch \.(eot|ttf|otf|svg)$><br />
 ExpiresDefault "access plus 10 years"<br />
 </FilesMatch><br />
 ExpiresByType application/x-font-opentype A315360000<br />
 ExpiresByType application/x-font-truetype A315360000<br />
 ExpiresByType application/x-font-ttf A315360000<br />
 ExpiresByType application/x-font A315360000<br />
 ExpiresByType font/opentype A315360000<br />
 ExpiresByType font/otf A315360000<br />
 ExpiresByType application/vnd.oasis.opendocument.formula-template A315360000<br />
 ExpiresByType image/svg+xml A315360000<br />
 ExpiresByType application/vnd.ms-fontobject A315360000<br />
 ExpiresByType font/woff A315360000<br />
 <FilesMatch \.(flv|wmv|asf|asx|wma|wax|wmx|wm)$><br />
 ExpiresDefault "access plus 10 years"<br />
 </FilesMatch><br />
 ExpiresByType video/x-flv A315360000<br />
 ExpiresByType video/x-ms-wmv A315360000<br />
 ExpiresByType video/x-ms-asf A315360000<br />
 ExpiresByType video/x-ms-asx A315360000<br />
 ExpiresByType video/x-ms-wma A315360000<br />
 ExpiresByType video/x-ms-wax A315360000<br />
 ExpiresByType video/x-ms-wmx A315360000<br />
 ExpiresByType video/x-ms-wm A315360000<br />
 <FilesMatch \.(swf|pdf|doc|rtf|xls|ppt)$><br />
 ExpiresDefault "access plus 10 years"<br />
 </FilesMatch><br />
 ExpiresByType application/x-shockwave-flash A315360000<br />
 ExpiresByType application/pdf A315360000<br />
 ExpiresByType application/msword A315360000<br />
 ExpiresByType application/rtf A315360000<br />
 ExpiresByType application/vnd.ms-excel A315360000<br />
 ExpiresByType application/vnd.ms-powerpoint A315360000<br />
</IfModule><br />
FileETag none<br />
<IfModule mod_deflate.c><br />
<FilesMatch "\.(php|html)$"><br />
SetOutputFilter DEFLATE<br />
</FilesMatch><br />
</IfModule><br />

```<br />
<br />
Please, Nota Bene:<br />
<br />
1 - This is NOT my full .htaccess (the missing code is security related, and powerful SEO rules. Sorry, this missing part will be NEVER reveled)<br />
<br />
2 - I do NOT say "My .htaccess is perfect". Nope! It's working fine for me. So, I hopefully it will work fine for you too!<br />
<br />
3 - You can (need) tweak it for your own needs.<br />
<br />
4 - My dozen of intermediary steps to get the few final points (for gaining the Grade A) are so terrible for a human being, that I prefer to NEVER publish them.<br />
[B][SIZE="3"]Now, your CS-Cart website should be faster![/SIZE][/B] [IMG]https://secure.hyves.org/images/smilies/default/smiley_running.gif[/IMG]<br />
<br />
Thanks for reading,<br />
<br />
<br />
Lee Li Pop<br />
<br />
[B][SIZE="3"]PS: Today, I found a freeware who can beat all the expensive "website accelerators" like WEBO, and how to use it for profit. <br />
<br />
Keep in touch with Lee Li Pop speed up channel![/SIZE][/B]

Hi Lee,

Just wanted to say thank you for all these great tips you have given us all.

Quick question about the above .htaccess file. Is this for use with Smartoptimizer?



Hello John,

Yes, if you read Step 2, and SmartOptimizer Source Code Disclosure Vulnerability, you will understand that I use SmartOptimizer, thus, yes, this “.htaccess” above is for running with SmartOptimizer.

However, John, update your SmartOptimizer for v1.8, and (try) to use a reliable web hosting company to have a fully secure cart:

[quote name=‘Lee Li Pop’]Hello The Tool,

[quote name=‘The Tool’]Here is the response I received from Ali Farhadi concerning the added htaccess file in SO.

[quote name=‘Ali Farhadi’]

But seems [SIZE=“3”]some hosts including yours doesn’t allow using php_value in .htaccess[/SIZE] which causes it to break.[/QUOTE][/QUOTE][/QUOTE]

[SIZE=“3”]Of course, use this “.htaccess” in addition of Step 1 and Step 2 to get the full power of my tweaks![/SIZE]

Happy to help!

Lee Li Pop

Hi Lee,

Thanks for all your tips.

I’m testing with CS Cart at the moment so have just added the .htaccess you provided.

Just a quick question, do you have eAccelerator installed and active on your server?

If so, do you have optimization and cache enabled?

Also, what type of caching have you selected in CS Cart?



Hello John,

[quote name=‘utilityempire’]

I’m testing with CS Cart at the moment so have just added the .htaccess you provided.[/QUOTE]

[SIZE=“3”]This “.htaccess” performs its best performances coupled with Step 1 and Step 2[/SIZE] :wink:

[quote name=‘utilityempire’]

Just a quick question, do you have eAccelerator installed and active on your server?[/QUOTE]

No I don’t, because I’m on a shared.

However, if I could afford a dedicated server or a VPS, I would use Alternative PHP Cache, because it will be included built-in to the core of PHP starting with PHP 6.

Source: [url]http://en.wikipedia.org/wiki/List_of_PHP_accelerators[/url]

On the other hand, the speed of my sites is very good, so I stay on a shared.

[quote name=‘utilityempire’]

Also, what type of caching have you selected in CS Cart?[/QUOTE]

I use mainly CS-Cart 1.3.5. It seems to me, there is NO cache there.

All my results that I talk, are based on CSC 1.3.5, however, it’s a personal release, very light with “performance” in mind.

Why “very light”?

Because I have only one CSS file. I cleaned and grouped the CSS code, and deleted all useless background images. Thereby, it weighs only 13Kb.

[quote name=‘utilityempire’]

Thanks for all your tips.[/QUOTE]

You’re welcome,

Lee Li Pop


Thanks for your advices, but as I get to step to of your tips and change htaccess file it messes all my tamplate what should I do?


Hello Maksis,

[quote name=‘maksis’][COLOR=“Red”]it messes[/COLOR] all my tamplate what should I do?[/QUOTE]

Sorry, I am not an English speaker. I don’t understand “[COLOR=”#ff0000"]It messes[/COLOR]".

Lee Li Pop

Lee Li,

Messes = Messes up, Screws up, Doesn’t work, Looks like crap.


Lee Li’s .htaccess should work fine for you. My guess is that you still have the smartoptimizer .htaccess file inside the smartoptimizer folder. Remove it, clear your cache and see what happens.


Hello Brandon,

Thank you for your explanations!

So, I understand “Doesn’t work” :wink:

So, Brandon, did you install this “.htaccess”?

If so, did you noted any increasing of your Yslow!?

Lee Li Pop

Lee Li,

I did install this .htaccess, but I didn’t notice any difference. My old .htaccess was pretty similar so that is probably why.

I did learn something though. I guess there are two types of yslow. There is a version 1 and a version 2. Apparently [url]http://gtmetrix.com/[/url] uses version 1 and gave me a “B” grade. When I run yslow on Firefox it shows that version 2 is an “A” and version 1 is a “B”.

Either way, I’m pretty happy. I never got that good of grades in school so if I’m getting A’s and B’s for my website than I must be doing something right.

I do appreciate your posts on speeding up the sites though. I did notice that doing things like enabling gzip along with smartoptimizer my site speed really increased.


Hello Brandon,

You’re absolutely right about Yslow!


1 - Did you implemented this advice about the head flush()?


2 - Did you minified and combined your CSS and Javascript files?

3 - Did you studied your “Waterfall View” from WebPageTest?


You can get a Yslow! Grade A with release 2, because I did!

Much more, do you know if you call an external Javascript as I explain in this post, you loose up to 4 points!?


Now, I work on implementation of Content Delivery Network (CDN) for CS-Cart… The game is not over, because I haven’t won yet…

Lee Li Pop

Lee Li,

I guess I missed the flush thing. I might have to take a look at it.

As for combining the JS and CSS files, I thought about it. I decided that upgrading my site is enough work already and I don’t really want to have to make more work for myself. There is no doubt that if I were to combine my CSS files that upgrading would be a huge pain in the neck for me where right now it is only a small pain.

I have kind of looked over the WebPageTest. I know that some simple things like optimizing some of my images will help.

I’d love to find out more about the CDN. For some reason my simple mind can’t figure out exactly how this works. No surprise I guess.


Lee Li, have you had any experience with “Xcache”?? I have been running it for 6 months. In Google Web Master tools my site went from Slow to Fast in the Labs section after I installed it so there is some benefit but I wondered if anyone else had tried it out.

Hello Brandon,

[quote name=‘brandonvd’]I guess I missed the flush thing. I might have to take a look at it.[/QUOTE]

With this simple added code, your website is faster to 1/2 second.


Hello Ion Cannon,

[quote name=‘Ion_Cannon’]Lee Li, have you had any experience with “Xcache”??[/QUOTE]

I would like, but I can’t, because I’m on a shared server…

However, if I could to use a PHP accelerator, I will choose APC, although eAccelerator is faster, because APC will be bundled in by default in PHP6.

[SIZE=“3”]It maybe possible to install a PHP accelerator in a shared hosting, but I do not know it.[/SIZE]

Lee Li Pop

Hello Lee!

Thanks for your tips, at the beginning I got grades D and D now its C and C.

I am wondering how can I make fewer requests on my website?

Thanks again!

Also as I put this code in my htaccess file I get 500 Erorr


RewriteCond %{REQUEST_FILENAME} -f

RewriteRule ^(.*.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt))$ smartoptimizer/?$1

ExpiresActive On

ExpiresDefault “access plus 10 years”

Header append Vary User-Agent

Header append Vary Accept-Encoding

Header append Cache-Control private

Header append Cache-Control public

Header unset ETag

FileETag None


Hello Maksis,

1 - Do you have Gzip running perfectly?

[quote name=‘Lee Li Pop’]

Test your page for gzip compression:



2 - Do you have SmartOptimizer running perfectly?

3 - Could you publish your [COLOR=“Red”]FULL[/COLOR] “.htaccess”?

Thank you,

Lee Li Pop

Hello Lee!

yesterday afternoon I managed to get B and C grades

  1. yes my gzip is running perfectly!

  2. I do have smartoptimazer but I dont know if its running perfectly.

  3. Here is my full htaccess file

    ```php DirectoryIndex index.html index.php

    RewriteEngine on

Some hostings require RewriteBase to be uncommented


Your store url is http://www.yourcompany.com/store/cart

So “RewriteBase” should be:

RewriteBase /store/cart

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !.(png|gif|ico|swf|jpe?g|js|css)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php?sef_rewrite=1 [L,QSA]

RewriteRule ^(..(js|css))$ smartoptimizer/?$1


RewriteCond %{REQUEST_FILENAME} -d

RewriteCond %{REQUEST_FILENAME}/index.html !-f

RewriteRule . index.php?sef_rewrite=1 [L,QSA]

compress text, html, javascript, css, 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

Or, compress certain file types by extension:

SetOutputFilter DEFLATE

SetOutputFilter DEFLATE

Turn on Expires and set default to 0

ExpiresActive On

ExpiresDefault “access plus 10 years”

ExpiresByType text/css A315360000

ExpiresDefault “access plus 10 years”

ExpiresByType text/javascript A315360000

ExpiresByType application/javascript A315360000

ExpiresByType application/x-javascript A315360000

ExpiresByType text/x-js A315360000

ExpiresByType text/ecmascript A315360000

ExpiresByType application/ecmascript A315360000

ExpiresByType text/vbscript A315360000

ExpiresByType text/fluffscript A315360000

ExpiresDefault “access plus 10 years”

ExpiresByType image/gif A315360000

ExpiresByType image/png A315360000

ExpiresByType image/jpeg A315360000

ExpiresByType image/x-icon A315360000

ExpiresByType image/bmp A315360000

ExpiresDefault “access plus 10 years”

ExpiresByType application/x-font-opentype A315360000

ExpiresByType application/x-font-truetype A315360000

ExpiresByType application/x-font-ttf A315360000

ExpiresByType application/x-font A315360000

ExpiresByType font/opentype A315360000

ExpiresByType font/otf A315360000

ExpiresByType application/vnd.oasis.opendocument.formula-template A315360000

ExpiresByType image/svg+xml A315360000

ExpiresByType application/vnd.ms-fontobject A315360000

ExpiresByType font/woff A315360000

ExpiresDefault “access plus 10 years”

ExpiresByType video/x-flv A315360000

ExpiresByType video/x-ms-wmv A315360000

ExpiresByType video/x-ms-asf A315360000

ExpiresByType video/x-ms-asx A315360000

ExpiresByType video/x-ms-wma A315360000

ExpiresByType video/x-ms-wax A315360000

ExpiresByType video/x-ms-wmx A315360000

ExpiresByType video/x-ms-wm A315360000

ExpiresDefault “access plus 10 years”

ExpiresByType application/x-shockwave-flash A315360000

ExpiresByType application/pdf A315360000

ExpiresByType application/msword A315360000

ExpiresByType application/rtf A315360000

ExpiresByType application/vnd.ms-excel A315360000

ExpiresByType application/vnd.ms-powerpoint A315360000


[quote name=‘Lee Li Pop’]Hello Brandon,

With this simple added code, your website is faster to 1/2 second.


I tried this code out, I don’t really have a clue about it but thought I would try it.

I don’t think it works correctly on my site though. Is it the

/skins/YOUR_SKIN/customer/index.tpl file that you ad this too?

When I compare the output I get for my site with chunkview shows basically the whole of my index page in chunk form-about 23 of them.

Was worth a try :slight_smile:

Thanks again Lee for more great suggestions.

Hello Maksis,

Your “.htaccess” is too different than mine.

Please use mine.

Of course, try it on your developing box (localhost) and check your Yslow! score before/after with Yslow! for firefox:


If you have NOT a developing box, install WAMP or XAMPP.

I use WAMP on my Windows box for years, and recommend it.

If you have a Linux box, follow my advices here:


Sorry, I am not a Mac Maniac :oops:

All the best,

Lee Li Pop