Forum Topic: Does using IfModule prevent 500 errors?
I am working my way through the sample WordPress .htaccess template and just seeing what works and what doesn’t for my environment. I am getting 500 internal server errors with certain directives but I thought that using the IfModule around various chunks of instructions was a way of gracefully avoiding these types of errors. Is this not true? Great book and thanks for taking the time to write it.
4 Replies to “Does using IfModule prevent 500 errors?”
Yes, that it is interesting indeed.. you are correct that the IfModule containers should prevent 500 errors when the module isn’t available. But also could be that the module is available, but there’s an issue with directives contained therein.. which sections were involved in the WP template?
It was the block of code dealing with “Enable file compression”. It just didn’t not like it and threw the 500 error. Right now I am simply leaving it out.
Perfect example of how a single misplaced character can crash the server.. in the template files and in the book on page 44, the SetEnvIfNoCase
directive is split into two lines, but the backslash that escapes the newline is misplaced. Instead of this:
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$
\^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
it should be this:
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ \
^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
This will be fixed in the next version of the book, and here in a few minutes for the template files :)
Thanks Jeff. Glad I asked. Appreciate the correction.