Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool How to enable GZIP through .httaccess file.

    I am new to this forum. My name is Wilfred Cooray from Sri Lanka.

    I have a problem in enabling GZIP of my website The Bible, Inspired Word of Eternal God".

    My .httaccess file content is as follows.

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^lovingword\.eu3.biz$ [NC]
    RewriteRule ^(.*)$ http://www.lovingword.eu3.biz/$1 [R=301,L]
    RewriteCond %{THE_REQUEST} ^.*/index.html
    RewriteRule ^(.*)index.html$ http://www.lvingword.eu3.biz/$1 [R=301,L]


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

    Thank you.

    Wilfred Cooray

  2. #2
    Senior Coder durangod's Avatar
    Join Date
    Nov 2010
    Location
    southwestern USA
    Posts
    1,939
    Thanks
    339
    Thanked 49 Times in 47 Posts
    Hi, do you have GZip enabled on the server itself? If so are you running cPanel ?
    Remember in PHP you shoot Objects with arrows Example: $name->id; then Arrays are $name['id'];

  3. #3
    New to the CF scene
    Join Date
    Jan 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool GZip enabling throug .httacces file

    Quote Originally Posted by durangod View Post
    Hi, do you have GZip enabled on the server itself? If so are you running cPanel ?
    Well I am running a CPanel. There in the root I have the .htaccess file. Can I enable GZip through this file. The code I have entered to activate GZip is in this file I have submitted in my Forum question.

    But when I tested There was a message to say file did not get enable.

    Thank you.

    Wilfred

  4. #4
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    2,601
    Thanks
    2
    Thanked 384 Times in 374 Posts
    gzip compression from .htaccess only does STATIC files. .php are not a static files, they are dynamically executed when you call them. To gzip compress the PHP you have to do it IN the PHP files, typically with the output buffer commands.

    <?php ob_start("ob_gzhandler"); ?>

    Apache and .htaccess don't even play into it. To that end including PHP in this line:

    mod_gzip_item_include file .(html?|txt|css|js|php|pl)$

    Does not a blasted thing, ever... well, unless php is not present/enabled/recognized by Apache and the code ends up sent as plaintext client-side instead of being run. Aka something that in normal practice should NEVER happen.

    side note -- that said your site has some serious usability and accessibility concerns, in particular in regards to the gibberish nonsensical markup that makes my braille reader spit out the page as if it were a single run-on sentence.

    Code:
    <body style="font-family:Verdana;">
    
    <div style="background-color:#ffffff;padding:15px;">
     <img src="/Images/wbannernew.jpg" alt="Word of God" width="1200" height="150"> 
      
    
    </div>
    
    <div style="overflow:auto">
      <div class="menu">
        <div class="menuitem"><a href="http://www.lovingword.eu3.biz/p.php">Prayer</a></div>
        <div class="menuitem"><a href="http://www.lovingword.eu3.biz/heal.php">Healing</a></div>
        <div class="menuitem"><a href="http://www.lovingword.eu3.biz/find.php">Research</a></div>
        <div class="menuitem"><a href="http://www.lovingword.eu3.biz/help.php">Help</a></div>
        <div class="menuitem"><a href="http://www.lovingword.eu3.biz/a.php">About</a></div>
        <div class="menuitem"><a href="https://inspiredwordoflovinggod.blogspot.com">My blog</a></div>
            
        <br><br>
        <a href="http://www.esvbible.org/devotions/daily-reading-bible" target="_blank"><img src="/Images/biblereadjp.jpg" width="180" height="150" alt='Daily Bible Reading'></a>
        <br><br>
        <h4>Daily Bible Reading</h4>
        <br><br>
    No... just... NO! Endless pointless DIV for nothing, image doing H1's job, DIV doing ul's job, DIV+classes doing LI's job, absolute URI's for nothing, attributes like target that haven't had any business on websites since 1997, H4 with no H3, H2, or H1 preceding it...

    If you're worried about gzip compression to save bandwidth, first you might want to focus on semantic markup and leveraging selectors to reduce the amount of HTML used and improve accessibility.

    Coded PROPERLY that would read more like this:

    Code:
    <body>
    
    <div id="top">
    	<h1>The Bible, Inspired Word of Eternal God</h1>
    	<ul id="mainMenu">
    		<li><a href="/p.php">Prayer</a></li>
    		<li><a href="/heal.php">Healing</a></li>
    		<li><a href="/find.php">Research</a></li>
    		<li><a href="/help.php">Help</a></li>
    		<li><a href="/a.php">About</a></li>
    		<li><a href="https://inspiredwordoflovinggod.blogspot.com">My blog</a></li>
    	 </ul>
    	 
    	<div id="extras">
    		<a href="http://www.esvbible.org/devotions/daily-reading-bible">
    			<img
    				src="/Images/biblereadjp.jpg"
    				alt="Daily Bible Reading"
    			>
    		</a>
    		<h2>Daily Bible Reading</h2>
    589 bytes vs your original's 1061 bytes. If your markup wasn't a bloated non-semantic mess you probably wouldn't need to be playing around with compression of the markup!

    LIKEWISE you might want to get all the static style and scripting out of the HTML so you can also leverage caching models. You're basically wasting 30k of HTML on your home page's code to deliver 5.4k of plaintext and only one image I would treat as content -- aka what has no excuse to be significantly more than around 12k of markup, and could possibly be done in as little as 8k.

    Even your keywords meta is utterly banjaxed, it's supposed to be seven or eight single words that exist between <body> and </body> as plaintext, not a place to blindly stuff endless word-jumbles of the SAME WORDS! ... and then people wonder why it ends up ignored. Used PROPERLY even Google will still pay attention to it despite wild claims to the contrary even by their own staff. You'd think NOBODY was using it properly!
    Last edited by deathshadow; 01-13-2018 at 07:11 AM.
    I would rather have questions that can't be answered, than answers that can't be questioned.
    http://www.cutcodedown.com

  5. #5
    New to the CF scene
    Join Date
    Jan 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry for the delay in replying you deathshadow. I am very much impressed with your reply. Compression is a subject I did not want to touch thinking I might make a mistake. You have taken lot of trouble to visit my site and given me an example on how to compress without the help from .htaccess file and GZIP..

    I will edit menu as you have shown.

    Regarding the keywords and content I agree with you. I do not understand how to get the most suitable keywords to my niche. The net result was the long line of keywords. i also agree with you about google. As you said Google is still interested in keywords.

    Thank you.

    In the begging of your reply you have mentioned about To gzip compress the PHP you have to do it IN the PHP files, typically with the output buffer commands.

    <?php ob_start("ob_gzhandler"); ?>

    Can you elaborate it more. Or do you recommend any tutorial for this. I would be very much grateful if you would help me in this regard.

    Once again I am very much grateful to you. Hope you will assist me more.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •