Frage

I'm having a problem where Wordpress is periodically and randomly destroying the .htaccess file and setting it to zero bytes. When it does this, the site of course breaks until permalinks are manually flushed and .htaccess is rewritten. How can I protect the .htaccess file completely (total read only) or otherwise prevent Wordpress from ever automatically overwriting it? My FTP client won't allow me to set the permissions lower than 644 so I can't make it true read only.

War es hilfreich?

Lösung

Fixed this by changing permission on .htaccess to 444 from CPanel's file manager. For some reason my FTP client - even though logged in as the same CPanel user - could not make the change and the file would always revert back to 644. Cpanel had no such problem at all.

Andere Tipps

Normally WordPress does only affect rules between # BEGIN WordPress and # END WordPress, rules before or after this section should be left alone.

Basic example from the codex htaccess entry:

### custom rules

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

### custom rules

You can find some important functions in /wp-admin/includes/misc.php, like save_mod_rewrite_rules() and insert_with_markers(). The compilation of rules is done by WP_Rewrite.

My issue was: no matter what I do, .htaccess in my public_html was being created with 444 permissions and the code which was breaking the wp-admin.

How I solved: under wp-includes, I found htaccess.txt and deleted it. Then I deleted .htaccess under public_html

Then after reloading the wp-admin page, issue was resolved :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit wordpress.stackexchange
scroll top