Support » Plugin: All-In-One Security (AIOS) – Security and Firewall » Could not write to the .htaccess file. Please check the file permissions.

  • Resolved cheddargeorge

    (@cheddargeorge)


    Hi.

    I have All In One WP Security installed, but whenever I try to do anything which entails it writing to .htaccess then it fails with “Could not write to the .htaccess file. Please check the file permissions.”

    However, the .htaccess permissions appear fine (even WP Security says so in the filesystem security tab), and are set to 644, and the root directory (i.e. the main WP directory in which .htaccess resides) is 755.

    This is on a CentOS server, running Apache, and the file has ownership of apache:apache (i.e. owner of apache and group of apache), which it should do.

    Any assistance would be much appreciated. Thanks!

Viewing 15 replies - 1 through 15 (of 36 total)
  • Plugin Support vupdraft

    (@vupdraft)

    644 should be OK (mine are also set to this). Do you have any other security plugins such as iThemes?

    Thread Starter cheddargeorge

    (@cheddargeorge)

    Hi @vupdraft.

    No, there are no other security plugins.

    Plugin Support vupdraft

    (@vupdraft)

    It could be that you don’t have a .htaccess. Can you try flushing your permalinks, to do this;

    In the WordPress admin area, go to “Settings > Permalinks”
    Click “Save Changes”

    Your Permalinks and rewrite rules should then be flushed. Can you then try making some changes to your settings

    Thread Starter cheddargeorge

    (@cheddargeorge)

    The .htaccess file exists and works fine. In fact WP Security even has no problem making a backup copy of it. It’s just that when it comes to actually writing anything to it that WP Security fails every time, even though permissions and ownership are correct.

    dragonsway76

    (@dragonsway76)

    I can verify this bug as well. I am on Ubuntu 20.04 LAMP, virtualmin control panel, same exact symptoms described above. I tried

    wp rewrite flush

    , but no luck.

    Correct permissions:
    https://i.imgur.com/OvZFsZA.png

    Write Failures:
    https://i.imgur.com/Lg2QnxP.png

    No other security plugins… how I am using litespeed cache… (However, I used the “Disable All FEatures” option in litespeed and still get this error.)

    Update:
    I tried change the .htaccess permission to 660, but no luck the problem remains… aiowps can’t write to .htaccess

    Plugin Support vupdraft

    (@vupdraft)

    Can you check if your .htaccess is enabled with AllowOverride#
    If the AllowOverride directive is set to None then this will disable all .htaccess files. In order to verify this, open the Apache configuration file (typically called httpd.conf or apache.conf) and check that the AllowOverride directive is set to AllowOverride All. If you needed to make changes to your Apache config, remember to save the file and restart Apache using the following command;

    sudo service apache2 restart

    hhhmm no luck..

    I am using virtualmin, which has “virtual servers with their own” apache.conf files, for this particular virtual server I verified that AllowOverride is already set to “All”

    <Directory /home/admin/public_html>
        Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch 
        allow from all
        AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
        Require all granted
    </Directory>
    <Directory /home/adminbca/cgi-bin>
        allow from all
        AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
        Require all granted
    </Directory>

    Then I went to the master configuration at /etc/apache2/apache2.conf

    And changed that to AllowOverride None to AllowOverride All disabed all caching and restarted apache2…

    same problems :-/

    Thread Starter cheddargeorge

    (@cheddargeorge)

    Yeah, I concur. Still the same issue. AllowOverride All has always been enabled in my Apache config (CentOS: /etc/httpd/conf/httpd.conf) for the virtual host in question, and is not overridden in .htaccess.

    So, still not working.

    Plugin Support vupdraft

    (@vupdraft)

    Apologies for the ongoing inconvenience. I have asked one of our developers to have a look at this.

    Plugin Contributor Prashant Baldha

    (@pmbaldha)

    @cheddargeorge @vupdraft @dragonsway76 @cheddargeorge It looks like your PHP web server is not owner of the .htaccess file.

    There are two options two resolve the issue:

    1. Give the fie permission either 0664 (owner and group user can write) or 0646 (owner and public can write) or 0666 (owner, group user and public can write) to your .htaccess file. Please try permission in left to right order.

    2. Set owner of the .htaccess file to the server runner. It is a little bit technical thing. For it, you can consult the server administrator or hosting provider support.

    Hope this helps you.

    1.) The site owner already owns the .htaccess file and by default it has 644 permissions as recommended by your plugin and others.

    $ stat .htaccess
    File: .htaccess
    Size: 1152 Blocks: 8 IO Block: 4096 regular file
    Device: fd00h/64768d Inode: 569064 Links: 1
    Access: (0644/-rw-r–r–) Uid: ( 1021/admin) Gid: ( 1021/admin)
    Access: 2022-07-06 12:30:03.994688454 +0800
    Modify: 2022-07-05 12:20:33.762703188 +0800
    Change: 2022-07-05 12:20:33.762703188 +0800
    Birth: –

    Does Not Work

    2.) I tried 646

    $ stat .htaccess
    File: .htaccess
    Size: 1152 Blocks: 8 IO Block: 4096 regular file
    Device: fd00h/64768d Inode: 569064 Links: 1
    Access: (0646/-rw-r–rw-) Uid: ( 1021/admin) Gid: ( 1021/admin)
    Access: 2022-07-06 12:30:03.994688454 +0800
    Modify: 2022-07-05 12:20:33.762703188 +0800
    Change: 2022-07-07 07:12:47.399340478 +0800
    Birth: –

    Does Not Work

    3.) I tried 666,

    $ stat .htaccess
    File: .htaccess
    Size: 1152 Blocks: 8 IO Block: 4096 regular file
    Device: fd00h/64768d Inode: 569064 Links: 1
    Access: (0666/-rw-rw-rw-) Uid: ( 1021/admin) Gid: ( 1021/admin)
    Access: 2022-07-07 07:13:31.999339083 +0800
    Modify: 2022-07-05 12:20:33.762703188 +0800
    Change: 2022-07-07 07:14:48.303336696 +0800
    Birth: –

    Does Not Work

    Thread Starter cheddargeorge

    (@cheddargeorge)

    @plugin Support

    Your suggestions are nonsense. I already said in the original question that the
    permissions and ownership of .htaccess are correct.

    Your plugin doesn’t work.

    @cheddargeorge has a point. It does oddly seem that a very popular plugin has somehow lost the ability to be installed and configured correctly. This bug, plus my other bug with this plugin. seems to make your plugin completely useless to new users as fundamental installation & configuration cannot be completed. I like open-source projects I hope you guys can sort this out.

    Plugin Contributor Prashant Baldha

    (@pmbaldha)

    Can you please try to give permission of 0777 temporary and then try? If it works, you must revert the .htaccess file permission to the 0644.

    $ stat .htaccess
    File: .htaccess
    Size: 1152 Blocks: 8 IO Block: 4096 regular file
    Device: fd00h/64768d Inode: 569064 Links: 1
    Access: (0777/-rwxrwxrwx) Uid: ( 1021/admin) Gid: ( 1021/admin)
    Access: 2022-07-08 07:20:19.676927303 +0800
    Modify: 2022-07-05 12:20:33.762703188 +0800
    Change: 2022-07-08 10:36:55.716629192 +0800
    Birth: –

    Does not work… same error. :-/

Viewing 15 replies - 1 through 15 (of 36 total)
  • You must be logged in to reply to this topic.