.htaccess crashes my wordpress website

Posted August 8, 2016 7.3k views
UbuntuWordPressDigitalOceanDigitalOcean 1-Click Apps Marketplace

Ok, I’ve struggled with this problem for several days now, and I don’t know how to fix it. Apparently I need to create an .htaccess file in order to allow my users to start accessing the posts and pages in my wordpress website, but adding an .htaccess in /var/www/ just crashes the website. No error 500 or anything. Straight up crashes the website.

Here’s the code that I put into htaccess, seemed pretty ok to me…

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

But the server just crashes. I’ve tried to see what was wrong by typing in apache2 -S in the console, but all I got was:

Apache error: Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

I don’t even know what that means… In any case, I checked that mod rewrite was indeed on, and I’ve also allowed overrides in 000-default.conf. And yet my site still crashes. Does anyone know how I can fix this..?

P.S. I’ve checked the apache2 error logs, and found hundreds of lines that said PHP warnings. I don’t know what that means or how I should fix it, but maybe that’s related to all this?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
6 answers

It might happen due to the W3TC Cache plugin as it modifies your .htaccess file to include all that info. You will need to remove this plugin and then use the above code of .htaccess.


can you display a part of apache log from /var/log/apache2? Do you have enough permissions on apache config for your sites? Try creating /var/log/apache/mutex writable directory and restart apache (service apache2 restart).

Kind regards,
Milan Bozic.

Hello, thank you for such a quick answer, @milanbozic

I’ve tried creating a mutex directory in both /var/log/apache2 and /var/log/apache, but I not nothing from either of them.

Also, here is a part of the apache error log.

[Mon Aug 08 00:06:39.102129 2016] [:error] [pid 25184] [client] PHP Warning:  fopen(/var/www/,woocommerce,style,style,bootstrap,fontawes_387a8dcdea67a42bcdec5a634e8d6454): failed to open stream: No such file or directory in /var/www/ on line 100, referer:
[Mon Aug 08 00:06:39.102153 2016] [:error] [pid 25184] [client] PHP Warning:  flock() expects parameter 1 to be resource, boolean given in /var/www/ on line 101, referer:
[Mon Aug 08 00:06:39.102159 2016] [:error] [pid 25184] [client] PHP Warning:  stream_get_contents() expects parameter 1 to be resource, boolean given in /var/www/ on line 102, referer:
[Mon Aug 08 00:06:39.102164 2016] [:error] [pid 25184] [client] PHP Warning:  flock() expects parameter 1 to be resource, boolean given in /var/www/ on line 103, referer:

Judging by that log you have problem with Better WP Minify plugin, that plugin is outdated anyway. Disable it and give that code in .htaccess a try.

It worked! Thank you so much!

  • I was glad to help. By the way I now noticed that you get high volume of traffic on your site, 3 things to pin point: 1) minimum 30% of your visitors are just bots which eats bandwidth and slow your server down, you need to block them (and robots.txt and .htaccess block of bad bots is not so effective and also can slow server, you need to stop them on server level, that’s easy if you use nginx or varnish in front) ; 2) You should not really use apache for that, nginx handle that better; 3) You should use caching system (I recommend Varnish). Kind regards.

i have put the expires header into .htaccess in worpress html using panel, when i add that and save that code. and went to my website url. its got crashed and given me the following error.
“Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.”