We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Speed up your website with the perfect .htaccess file | Forum

Pete
Pete Apr 1 '13

I was doing some research about the guidelines that Google and Yahoo offer for speeding up websites, and kind of found that the quickest thing that you could do is add this code to your.htacces file.With this quick trick you can speed up your website dramatically. Of course, I’m assuming the use of Apache web server which uses this file. This should give you a big boost in performance of your website

 

 

 

# disable the server signature
ServerSignature Off

# Enable compression
<IfModule mod_deflate.c>
  <FilesMatch "\.(js|css|php|eot|ttf|otf|svg)$">
    SetOutputFilter DEFLATE
  </FilesMatch>
</IfModule>

# Control ETags which is thought that bring better performance
<IfModule mod_headers.c>
    Header unset ETag
</IfModule>
FileETag None

<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary Accept-Encoding
  </FilesMatch>
</IfModule>

<IfModule mod_expires.c>

    # Enable expirations
    ExpiresActive On

    # Default directive
    ExpiresDefault "access plus 1 month"

    # My favicon
    ExpiresByType image/x-icon "access plus 1 year”

    # Images
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"

    # CSS
    ExpiresByType text/css "access 1 month”

    # Javascript
    ExpiresByType application/javascript "access plus 1 year"

</IfModule>

The Forum post is edited by Pete Apr 1 '13
Rahul verma
Rahul verma Apr 2 '13
what about useing cloudflare.com? it have a free version n it work perfect with many things i am using it ..
suresh kumar
suresh kumar Apr 2 '13
Cloudflare increases your server load
Rahul verma
Rahul verma Apr 2 '13
what u mean by server load? o.O , they just compress ur everything n run a copy of ur site when server go down.
Wilson
Wilson Feb 20 '14

I have  a few question...

1. Do you add this coding to just the root (oxwall folder) .htacces file or do you add it to every .htacces files within the oxwall folder...Every Plugin has an .htacces file along with other folders within the root folder.

2. Do you add this coding to the bottom of the .htacces file because there is other coding within the.htacces file already.

here's what's on my now...
----------------------------------------------------------------------------
Options +FollowSymLinks
RewriteEngine On

AddEncoding gzip .gz
AddEncoding gzip .gzip
<FilesMatch "\.(js.gz|js.gzip)$">
  ForceType text/javascript
</FilesMatch>
<FilesMatch "\.(css.gz|css.gzip)$">
  ForceType text/css
</FilesMatch>


RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/
RewriteCond %{REQUEST_URI} !/ow_cron/run\.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php

---------------------------------------------------------------------------------------

Wilson

The Forum post is edited by Wilson Jul 30 '15
Weird Rat
Weird Rat Feb 20 '14
Cloudflare not only increases the server load but reads out all your information and information about your users, who is online, how long, where they come from - IP - and how they are connected, their account informations, when they purchase something and so on .. and its an US-company so NSA and Homeland Security have access to all those informations !
Mohammad
Mohammad Feb 21 '14
@Wilson

1-just root directory of Oxwall

2-I usually add this kind of code at the buttom of the file


Mohammad

Marylynn
Marylynn Jul 30 '15
Hey I know this is an old post but this is something I need to do.  I am having the same problems.  Just looking where to start first!!!
matt
matt Jul 30 '15
Wilson
Wilson Jul 30 '15
hey Marylynn,

After I used this information, my speed score went from a 56 to 96 after using this. You can put the code at the bottom of your .htacces file.

Here's a few sites that you can use to check your website. Do a before and after test!
1. http://tools.pingdom.com/fpt/ (I used this one to get that 96 score)
2. http://www.webpagetest.org/ (I use this to tweak things)
3. https://gtmetrix.com/ (I use this as well to tweak things)

Adding these code will help in the long run and is wroth the time. The big boys do it, so can you!

Wilson
ketkew
ketkew Jul 31 '15
Whoohooo :)

Your website is faster than 77% of all tested websites (was 66%)
And google ranking from 63/100 to 73/100
The Forum post is edited by ketkew Jul 31 '15
Mr Winks
Mr Winks Aug 5 '15
@RAHUL verma

I have used cloudflare but this increase loading time of my website and website take lot of time to load. :(
tammy harris
tammy harris Aug 6 '15
my htacess

 <ifModule mod_php4.c>

 php_value zlib.output_compression 16386

</ifModule>


# handler for phpsuexec..

<FilesMatch "\.(css|style)$">

 SetHandler application/x-httpd-php

</FilesMatch>


    # Enable compression

<IfModule mod_deflate.c>

  <FilesMatch "\.(js|css|php|eot|ttf|otf|svg)$">  

  SetOutputFilter DEFLATE 

 </FilesMatch></IfModule>

<IfModule mod_headers.c>  

<FilesMatch "\.(js|css|xml|gz)$">   

 Header append Vary Accept-Encoding  

</FilesMatch>

</IfModule>
 <IfModule mod_expires.c>
    # Enable expirations  

  ExpiresActive On
    # Default directive  

  ExpiresDefault "access plus 1 month"
    # My favicon  

  ExpiresByType image/x-icon "access plus 1 year”
    # Images  

  ExpiresByType image/gif "access plus 1 month"  

  ExpiresByType image/png "access plus 1 month"  

  ExpiresByType image/jpg "access plus 1 month"  

  ExpiresByType image/jpeg "access plus 1 month"
    # CSS   

 ExpiresByType text/css "access 1 month”

    # Javascript 

   ExpiresByType application/javascript "access plus 1 year"
</IfModule>


RewriteCond %{HTTP_USER_AGENT} libwww-perl.* RewriteRule .* – [F,L]


RewriteCond %{HTTP_USER_AGENT} ^BackWeb [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^Bandit [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^BatchFTP [NC,OR

]RewriteCond %{HTTP_USER_AGENT} ^BecomeBot [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [NC]

# proxy BlockRewriteCond %{HTTP:VIA}  !^$ [OR]

RewriteCond %{HTTP:FORWARDED}  !^$ [OR]

RewriteCond %{HTTP:USERAGENT_VIA}  !^$ [OR]

RewriteCond %{HTTP:X_FORWARDED_FOR}  !^$ [OR]

RewriteCond %{HTTP:PROXY_CONNECTION}  !^$ [OR]

RewriteCond %{HTTP:XPROXY_CONNECTION}  !^$ [OR]

RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]

RewriteCond %{HTTP:HTTP_CLIENT_IP}  !^$RewriteRule ^(.*)$ - [F]

RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] 

RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] 

RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] 

RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] 

RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]

 RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]

 RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]

 RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] 

RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] 

RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] 

RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] 

RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR] 

RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR] 

RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR] 

RewriteCond %{HTTP_USER_AGENT} ^HMView [OR] 

RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR] 

RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR] 

RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR] 

RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR] 

RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR] 

RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR] 

RewriteCond %{HTTP_USER_AGENT} ^larbin [OR] 

RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR] 

RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR] 

RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR] 

RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR] 

RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR] 

RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR] 

RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR] 

RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR] 

RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR] 

RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR] 

RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR] 

RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR] 

RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR] 

RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR] 

RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR] 

RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR] 

RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR] 

RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]

RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]

RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]

 RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR] 

RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR] 

RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR] 

RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]

 RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR] 

RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]

 RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR] 

RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Wget [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Widow [OR] 

RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]

RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR] 

RewriteCond %{HTTP_USER_AGENT} ^Zeus RewriteRule ^.* - [F,L]

The Forum post is edited by tammy harris Aug 6 '15
Marcel
Marcel Aug 6 '15
I have only this

Options +FollowSymLinks
RewriteEngine On

AddEncoding gzip .gz
AddEncoding gzip .gzip
<FilesMatch "\.(js.gz|js.gzip)$">
  ForceType text/javascript
</FilesMatch>
<FilesMatch "\.(css.gz|css.gzip)$">
  ForceType text/css
</FilesMatch>


RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/
RewriteCond %{REQUEST_URI} !/ow_cron/run\.php
RewriteCond %{REQUEST_URI} !/e500\.php
#RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
Marcel
Marcel Aug 6 '15
Perf. grade 74/100
Requests 135
Load time1.73s
Page size 874.2kB
The Forum post is edited by Marcel Aug 6 '15
Taylor
Taylor Nov 21 '15
Does this work on version 1.8?
Marcel
Marcel Nov 21 '15
yes
ketkew
ketkew Nov 21 '15
jup :)
tammy harris
tammy harris Nov 22 '15
use htacess is like a hack better of in http.conf   so its in the server headers 
Tecca
Tecca Nov 22 '15
Yes, it's much better off in http.conf. Has anyone tried using Nginx as a frontend proxy to Apache? Seems like that set up would run well. I'm on Nginx without Apache.
Pages: 1 2 »