0

I am trying to enable Gzip compression on my wordpress website. But when i try to add the compression code, i am getting 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 [email protected] 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.

Apache/2.4.18 (Unix) OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.5.31 Server at www.coachhire4u.com Port 80


My .htaccess file,

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /


RewriteCond %{REQUEST_URI} ^/customer/quote/payment/
RewriteRule (\d+)/(\d+) http://www.coachhire4u.com/?c4u_payment_id=$1 

[L,R=301]


RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]


</IfModule>


# END WordPress

Compression code

 # Compress HTML File, CSS File, JavaScript File, Text File, XML File and Fonts
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf

Please help me to resolve this issue. I know there are similar posts, but none of them seem to help

thanks

5
  • Check your server logs whenever you get a 500 error, it will give you a big hint as to what's wrong. Commented Feb 15, 2017 at 15:52
  • How to check my server log? i am accessing the server through FTP Commented Feb 15, 2017 at 15:52
  • If you are using gzip in your PHP code, it might just not be available in your PHP install. Check phpinfo() for what has been compiled in and what hasn't. Commented Feb 15, 2017 at 15:54
  • If it's a dedicated server, it's somewhere in /var/log. If it's a shared server, they usually give you a way to access your server logs. Commented Feb 15, 2017 at 15:54
  • Sorry couldnt find it.. Is there any other way that you can debug this issue? i am trying it for 2 days and its really upsetting me.. Commented Feb 15, 2017 at 15:58

2 Answers 2

3

There are different approchaes of achieving compression. Which one to use depends on the capabilities/setup of your server. It's always a good idea to surround blocks with <ifModule></ifModule> where possible, in order to prevent 500 status errors.

There's a good chance that the following will work on your local machine as well as on your server. However, with the sparse informatione provided, it's not possible to give a definite answer. But I'll gladly update this answer if this does not work and you can provide further debugging information.

<ifModule mod_gzip.c>
 mod_gzip_on Yes
 mod_gzip_dechunk Yes
 mod_gzip_item_include file .(html?|txt|css|js|json|php|pl|svg)$
 mod_gzip_item_include handler ^cgi-script$
 mod_gzip_item_include mime ^text/.*
 mod_gzip_item_include mime ^application/x-javascript.*
 mod_gzip_item_include mime ^application/json.*
 mod_gzip_item_exclude mime ^image/.*
 mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<ifModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
 AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml
 AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
 AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript application/json
 AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
 AddOutputFilterByType DEFLATE font/truetype font/opentype
</ifModule>
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
Sign up to request clarification or add additional context in comments.

7 Comments

thanks for your reply. When i add something with <ifModule> tag, it has no effect. So if i add it without the tag, it gives error.
"it has no effect" => did you check the response headers of your get requests? Did you also try only using the mod_gzip-part without the <ifModule>? If so, did it also result in an error?
i have added the above code now. But still the number doesnt go up. when i remove the <ifmodule> i am getting the same server error
Are you sure that either mod_gzip or mod_deflate are enabled in the httpd.conf of your web server at all? If it's a shared hoster, you'll have to ask their support.
|
1

It might be a bit late, but I hope this helps.

I fixed my error by going to httpd.conf for my Apache server configuration and uncommenting the lines containing mod_filter.so and mod_deflate.so.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.