Support » Plugin: SG Optimizer » PHP Version change can break .htaccess

  • Resolved Soft79

    (@josk79)


    FYI: After using the “Manual PHP Change” function of SG Optimize 5.0, my .htaccess was corrupted.

    My original .htaccess contained this line:

    
    AddHandler application/x-httpd-php70 .php .php5 .php4 .php3 .php2
    

    After switching version it was replaced it by this:

    
    # START PHP VERSION CHANGE forced by SG Optimizer
    AddHandler application/x-httpd-php72 .php .php5 .php4 .php3
    # END PHP VERSION CHANGE
     .php2
    

    Please notice the rogue .php2

Viewing 6 replies - 1 through 6 (of 6 total)
  • Yep, also here, same problem!

    [Wed Dec 05 11:28:48.472747 2018] [core:alert] [pid 22112] [client hidden_url] /home/hidden_url/public_html/hidden_url/.htaccess: Invalid command ‘.php2’, perhaps misspelled or defined by a module not included in the server configuration, referer: https://www.hidden_url.hidden_url/wp-admin/admin.php?page=sg-cachepress

    answer from SiteGround support:

    We performed multiple tests and and were able to figure out what is causing the issue. I will try to explain in detail below.

    When our default AddHandler is present in your .htaccess file, the plugin works properly and the issue does not occur. For example, when your .htaccess contains the the following:

    Code:
    AddHandler application/x-httpd-php70 .php .php5 .php4 .php3

    and the PHP version is changed via the SG Optimizer plugin, the above line simply gets changed to:

    Code:
    # START PHP VERSION CHANGE forced by SG Optimizer
    AddHandler application/x-httpd-php71 .php .php5 .php4 .php3
    # END PHP VERSION CHANGE

    However, if an .htaccess file contains a different/custom AddHandler, changing the PHP version from the SG Optimizer plugin will indeed trigger the issue.

    For example, if an .htaccess file contains the following (which is what has happened in your case):

    Code:
    AddHandler application/x-httpd-php70 .php .php5 .php4 .php3 .php2

    changing the PHP version through SG Optimizer would modify the first part of the AddHandler as follows:

    Code:
    # START PHP VERSION CHANGE forced by SG Optimizer
    AddHandler application/x-httpd-php71 .php .php5 .php4 .php3
    # END PHP VERSION CHANGE

    while the rest of the line will remain on a separate line in the .htaccess file thus causing the issue:

    Code:
    .php2

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    On it…

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    Released 5.0.5 and fixed this. Could you verify it’s working fine now?

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    We haven’t heard back from you in a while, so I’ve gone ahead and marked this thread as resolved.

    If you’re still having issues with SG Optimizer, please feel free to open another thread!

    Thanks!

    Hi, sorry I missed the previous replies.

    I haven’t tested it because I changed it manually. Good to see this was picked up immediately. As always excellent response time from SiteGround.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP Version change can break .htaccess’ is closed to new replies.