Custom Code – mod_gzip htaccess custom code not working

Home Forums BulletProof Security Pro Custom Code – mod_gzip htaccess custom code not working

Tagged: 

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #5631
    Krzysztof
    Participant

    I have a custom htaccess section and it is not working for me when I test it on pingdom tools or gtmetrix or page speed. Here is the code which worked on the free version:

    # CUSTOM CODE BOTTOM
    Header unset Pragma
    FileETag None
    Header unset ETag
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(html?|txt|css|js|php)$
    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.*
    
    <FilesMatch "\.ico$">
    Header set Expires "Mon, 20 Apr 2015 23:30:00 GMT"
    
    <FilesMatch "\.js$">
    Header set Expires "Mon, 20 Apr 2015 23:30:00 GMT"
    
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.infolotnicze.pl/$1> [R,L]
    #5632
    AITpro Admin
    Keymaster

    I can’t really tell you if that code would work or not.  It would depend on what your Server allows.  You will need to check with your Host about that.

    This type of code would go in the Bottom Custom Code text box for your Root .htaccess file.

    CUSTOM CODE BOTTOM: Add miscellaneous custom htaccess code here 
    ONLY add valid htaccess code below or text commented out with a pound sign # 

    #5636
    Krzysztof
    Participant

    It worked ok on the free BPS version. I have placed it in the right section but still no go for me ;(

    #5637
    AITpro Admin
    Keymaster

    The .htaccess file for BPS free and BPS Pro are pretty much identical so if you had it working on the free version then maybe try putting this custom code at the top of your root .htaccess file instead of the bottom.  Sometimes that does make a difference.

    #5639
    Krzysztof
    Participant

    Important note if you are using wordfenece – you have to turn off login security as there is a conflict and users are locked out automaically even if they type everything corectly

    #5642
    AITpro Admin
    Keymaster

    Yep, there was a conditional code wrap that needed to be added for this issue.  It has been added to the version in the Secure Download Area if you would like to install that now.  We have a couple of additional code corrections to make and will be releasing a new version of BPS Pro in a couple of days.

    Note: You can only use 1 Login Security feature at a time since they would both be doing the same authentication processing and would conflict with each other.  The conditional check that was added ensures that if BPS Pro Login Security is turned off then all authentication processing by BPS Pro is completely off.

    #5658
    AITpro Admin
    Keymaster

    Personal Note for myself:  As it turns out this had to do with permission settings for the .htaccess file.  Setting the file permissions for the root .htaccess file from 404 to 644 allowed mod_gzip to process the .htaccess rules.  Not sure if this is specific to this particular Server configuration or not.  I assume that this has to do with an Ownership issue.  Ie 644 allows the root .htaccess file to be processed by the Server since it is owned by the Server itself.

    #12254
    cmagnet
    Participant

    Hello, I am having a problem with adding GZIP custom code to my website which runs the free version of BPS. I watched your custom code video and I changed also the .htaccess file permissions to 644 and I am trying to add the following code:

    # 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
    AddType x-font/otf .otf
    AddType x-font/ttf .ttf
    AddType x-font/eot .eot
    AddType x-font/woff .woff
    AddType image/x-icon .ico
    AddType image/png .png

    I am adding this code on the Custom Code > Root htaccess File Custom Code > “CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE” and it supposed to be changing the following line only (since it’s the only one highlighted in yellow):

    # CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE

    which I guess is just a comment.

    Now, I am normally supposed to turn back to the first tab of the BPS tool “Security Modes” and click Activate, but when I do that it redirects me to [mywebsite’s domain]/wp-admin/admin.php?page=bulletproof-security/admin/options.php which is a 404 error.

    Any idea on how to fix this or how to activate the GZIP compression?

    #12263
    AITpro Admin
    Keymaster

    Tyically a 404 error means that either you are using invalid code (not allowed) for your particular Server/website, invalid code in general, an invalid custom permalink structure or using the .html permalink hack or 1 or both of these problems in the links below is causing the problem.

    cPanel HotLink Protection Tool Problem
    http://forum.ait-pro.com/forums/topic/read-me-first-pro/#cpanel-hotlink-protection

    WordPress flush_rewrite_rules function problem
    http://forum.ait-pro.com/forums/topic/read-me-first-pro/#flush-rewrite-rules

    Also please watch the Custom Code Video Tutorial to ensure you are doing the Custom Code steps correctly:  http://forum.ait-pro.com/video-tutorials/#custom-code

    #12264
    AITpro Admin
    Keymaster

    Actually it is probably caused by your code itself.  Please check with your web host and ask them if they allow all of this code on your particular Server/website.  Host Servers allow or disallow certain code and there are many different possibilities so the best idea would be to contact your Host to ask them what they do allow or disallow on their Servers.

    #12268
    AITpro Admin
    Keymaster

    Just for the heck of it use/test the Speed Boost Cache code in the link below on your website and see if it works.  If it works you can probably build onto the code / build up your specific code for your website needs.

    http://forum.ait-pro.com/forums/topic/htaccess-caching-code-speed-boost-cache-code/

    #12497
    cmagnet
    Participant

    OK I visited the links you posted to me above and I saw that my cPanel’s Hotlink options contained the code:

    (%0A|%0D|%27|%3C|%3E|%00)
    \.opendirviewer\.
    ^.*demo5.local.*
    users\.skynet\.be.*

    which was something I had to remove. I managed to remove it and switched back the rights of the Root .htaccess to 404/644 and I still cannot get to root htaccess file. I get the following error:

    501 Method Not Implemented

    GET to /wp-admin/admin.php not supported.
    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

    Thing is, I tried commenting the “Options -Indexes” and the “DirectoryIndex” as stated on the 500 error guide but I couldn’t get to update the current .htaccess. Any ideas?

    #12500
    AITpro Admin
    Keymaster

    Update: This turned out to be a common known problem with the cPanel Hotlink tool itself. The tool misinterprets existing htaccess code in htaccess files. The only known working solution is to disable and not use the cPanel Hotlink tool.

    This is probably a mod_security issue/problem.  Click the link below and try the troubleshooting steps in that Forum Topic to determine if mod_security is the cause of the issue/problem.

    http://forum.ait-pro.com/forums/topic/how-to-create-htaccess-file/

    #12502
    AITpro Admin
    Keymaster

    I see the this line of code:  ^.*demo5.local.* that you posted above, which is the demo domain where BPS is developed.  What should be there instead is your domain.

    Did you click the Activate buttons?

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.