1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

htaccess file

Discussion in 'Web Design' started by Mydragonsfly, Jan 19, 2014.

Tags:
  1. Mydragonsfly

    Mydragonsfly Newbie

    Joined:
    Feb 7, 2013
    Messages:
    9
    Likes Received:
    1
    Occupation:
    High school
    Hey guys.

    Just earlier this week I purchased my first domain for a small chunk of change at hostgator, moving up from my free hosting at weebly. When I was milling about my old website everything was nice. I stayed updated, was bouncing the middle of the first page on google, nothing much more on weebly I could do aside from link building... Something I've always been curious about was speeding up my website. I found a good little site called GTmetrix. My site wasn't as fast as it could be, so I did all I could do make it faster. Optimized images, specified image sizes, minified html and css and so forth. One thing however that has always eluded me on weebly was the ability to access the htaccess file to help my scores in the leverage browser caching / cache control headers (same thing?) and add expires headers departments.

    Now that I have my own website I am able to access that file. I'm trying to edit that file so I can up those scores. I have information pulled off of those two pages in my header, but I have no idea if I'm applying it correctly because nothing is happening.

    Also, if anyone knows how I can control cookies, that would be most helpful.

    If anyone needs to, I can give them a copy of the htaccess file I'm currently working with. And yes don't you guys worry, I have the original copy too. ;)
     
  2. trajek

    trajek Newbie

    Joined:
    Nov 29, 2010
    Messages:
    44
    Likes Received:
    10
    Location:
    Austin, Tx U.S.A
    Home Page:
    This page might help you with what your trying to do. http://www.askapache.com/htaccess/htaccess-fresh.html
     
  3. NojWang

    NojWang Newbie

    Joined:
    Dec 19, 2011
    Messages:
    42
    Likes Received:
    15
    Occupation:
    Entrepreneur
    Location:
    Canada
    .htaccess is a beautiful thing and extremely powerful so +1 for making a backup. Found some on hostgator which might help. http://blog.hostgator.com/2013/03/26/7-ways-to-speed-up-your-website/ - specifically #6 Turn on Gzip compression. Feeling the speed difference is sometimes not as noticeable as you might think. I like to use impartial tools to show me the subtle differences which you will not pickup on by hitting F5. http://tools.pingdom.com/fpt/ is my current favorite. Hope this helps.
     
    • Thanks Thanks x 1
  4. tahworld

    tahworld Regular Member

    Joined:
    Aug 16, 2013
    Messages:
    457
    Likes Received:
    393
    Location:
    ✔✔✔✔✔✔✔
    Yes, turn on Gzip.
    Watch out with caching, it can get really annoying when it won't update your changes.
     
  5. Mydragonsfly

    Mydragonsfly Newbie

    Joined:
    Feb 7, 2013
    Messages:
    9
    Likes Received:
    1
    Occupation:
    High school
    NojWang, thanks, I've known about pingdom, but I'll look into this article you linked me to.

    Also, if your any good with wordpress, please view this topic.

    • Black Hat SEO
    • Blogging
    • WordPress help - Ask your questions
    • Post 1053
     
  6. lucasbraydon

    lucasbraydon Supreme Member

    Joined:
    Nov 9, 2013
    Messages:
    1,232
    Likes Received:
    1,561
    Location:
    Here and there
    This is what I put into my .htaccess file and it works fine.

    Code:
    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/x-javascript "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 2 days"
    </IfModule>
    ## EXPIRES CACHING ##
    
    
    # BEGIN Cache-Control Headers
    <IfModule mod_headers.c>
    <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
    Header set Cache-Control "public"
    </filesMatch>
    <filesMatch "\.(css)$">
    Header set Cache-Control "public"
    </filesMatch>
    <filesMatch "\.(js)$">
    Header set Cache-Control "private"
    </filesMatch>
    <filesMatch "\.(x?html?|php)$">
    Header set Cache-Control "private, must-revalidate"
    </filesMatch>
    </IfModule>
    # END Cache-Control Headers
    
    
    
    
    # compress text, HTML, JavaScript, CSS, and 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
    
    
    # remove browser bugs
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
    
     
    • Thanks Thanks x 1
  7. Mydragonsfly

    Mydragonsfly Newbie

    Joined:
    Feb 7, 2013
    Messages:
    9
    Likes Received:
    1
    Occupation:
    High school
    lucasbraydon, thanks for the input with what code works with you. I'll test it out and (since it's so late) get back to you tomorrow. I'm curious as to where that code should go exactly. I've narrowed down the part of the htaccess file that I'm looking at, but I'm still somewhat unsure of what I should delete and where I should input the new code. Suggestions?

    Code:
    (^/|\.html)$" HTML_FILE
    Header add Pragma "no-cache" env=HTML_FILE
    Header add Cache-Control "no-cache, no-store, max-age=0, must-revalidate" env=HTML_FILE
    Header add Expires "-1" 
    env=HTML_FILE
    RewriteEngine On
    #
    Sorry to make a topic withenn a topic but I'd rather not spam the forums. Since I cant edit my OP this will do.

    If anyone knows about expires headers, help with that would be great, from what I've learned this is how I have them set up in all my images html currently:
    Code:
    <img src="img.link" hspace="10" vspace="10" width="378" height="155" align="left" border="1" alt="Cash machine" meta http-equiv="expires" content="Mon,3 Mar 2014 11:59:59 GMT" />
    I also have the same thing set up in the header code as well and have been going between those for the past few days to see which has the best effect, so far I haven't seen any changes.
     
    Last edited: Jan 23, 2014
  8. lucasbraydon

    lucasbraydon Supreme Member

    Joined:
    Nov 9, 2013
    Messages:
    1,232
    Likes Received:
    1,561
    Location:
    Here and there
    I just put it in after whatever is already there. Just find some space after everything else and also you should use the WP super cache plugin too.
     
  9. Mydragonsfly

    Mydragonsfly Newbie

    Joined:
    Feb 7, 2013
    Messages:
    9
    Likes Received:
    1
    Occupation:
    High school
    lucasbraydon, again thanks for the code. It is set and I'll update this in another 24 - 48 hours. As for WP super cache, please refer to the area of the forums I previously specified.