Hi
Yesterday our blog was down with a "server error" - today I found out that the .htaccess file was wrong. The lines below (which should be the full content) were suddenly repeated about 20 times.
Any idea what can have cause this "multiplication" - and how I can stop it from happening again?
The file's permissions were set to 644. After removing all the extra lines everything works fine.
I'm also using AskApache to keep strangers out (which have kept hackers out after an attack some months ago :o)
Thanks,
Kjetil
PS I should add that this WP installation is not on the root of our site but in a sub-directory (/blogg). Frankly I thought that you need an .htaccess file only on the very root, which is obviously wrong.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blogg/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blogg/index.php [L]
</IfModule>
# END WordPress
It was almost certainly not a hack attempt. WP does sometimes replicate .htaccess content. You simply appear to have had an unusually bad case of "the duplicates".
I thought that you need an .htaccess file only on the very root
You can have an .htaccess file in every sub-directory if you need it.
My experience is that WP will sometimes duplicate the htaccess rewrite block even if you only view the permalinks section in admin and don't save changes. Best thing to do is get htaccess where you want it, and then change the file permissions to 444 to prevent either WP or anyone else from writing to the file.
I used to get that happening a lot to one of my blogs, 444 cured it.
Just remember to allow WP write access whenever you decide to play around with permalinks and check that the right rewrite rules have been writen before switching permisions back to 444.
Thanks guys
- I'll try the 444 trick even if I've learned that 644 should be correct. I never change the permalinks (other than when upgrading) so it shouldn't be any problem.
The site was down again this morning, this time with new code generated by AskApache. This is funny both because similar code (from AskApache) works fine in the two other WP installations on the site - but also because the changes must have happened while I was asleep (spooky).
I tick this issue Resolved - eventually I'll cry out again.
Thanks again,
Kjetil
kiwirev
Member
Posted 3 months ago #
How do you get at it to do the 444 thing?
You can either use an ftp client or your file manager in the cPanel. Find the file, right click on it, select permissions and you will see the options. Tick the check boxes on the far left or just type 444 in the space provided.
kiwirev
Member
Posted 3 months ago #
Found it and done it. Thanks. Here's hoping...
There's just one thing to remember: If you or your system has to do any changes to your .htaccess file, you will have to alter the permissions back to 644 while doing the changes.
That's what I've been told.
Kj
That's right; set permissions to 644 (or better) to edit or let WP write to the htaccess file, then change them back to 444. And if you edit yourself with a plain text editor, be sure you're using the correct text file attributes, like windows line breaks for windows servers, or you'll end up with junk characters and gremlins that will keep htaccess from working or throw a 500 server error.