While trying to solve a problem on my website, a recommendation about my .htaccess file I got was

First of all, please check on the server for all the different modules if they are enabled, and once they are, remove the


blocks. They are putting an unnecessary strain on your server.

I don't know where should I look to see if modules are active - is it in the CMS? in the httpd.conf file? in the files on my server? should I make a slight modification in the .htaccess as a test? But more than that, could the recommendation self be not appropriate? Thanks.

Here is the .htaccess file for which the recommendation has been made:

Options +FollowSymLinks -MultiViews
RewriteEngine on
AddHandler x-httpd-php .html .htm

<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 1 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 2592000 seconds"
  ExpiresByType text/javascript "access plus 216000 seconds"
  ExpiresByType application/x-javascript "access plus 216000 seconds"

<ifModule mod_headers.c>
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"

  <filesMatch "\\.(css)$">
    Header set Cache-Control "max-age=2592000, public"

  <filesMatch "\\.(js)$">
    Header set Cache-Control "max-age=216000, private"

  <filesMatch "\\.(xml|txt)$">
    Header set Cache-Control "max-age=216000, public, must-revalidate"

  <filesMatch "\\.(html|htm|php)$">
    Header set Cache-Control "max-age=1, private, must-revalidate"

<ifModule mod_headers.c>
  Header unset ETag

FileETag None

<ifModule mod_headers.c>
  Header unset Last-Modified

RewriteCond %{HTTP_HOST} !^(www\.)?foo\.com$
RewriteRule .? http://foo.com%{REQUEST_URI} [R=301,L]

#BEGIN WordPress
<IfModule mod_rewrite.c>

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php

# END WordPress
  • I think you need more information from the person who said that. What modules? Apache modules? What do they mean by "blocks"? Apr 14, 2011 at 9:41
  • Sorry, you're right, I've added the .htaccess file based on which the person made the recommendation. I don't really understand what they mean and couldn't get more details about that from them, that's why I ask here, thought that people with more knowledge than me could understand that easier. Just a second, I only now see that the question has been edited before being posted - I should have used code tags in the quote tag. Will edit right away!
    – keiki
    Apr 14, 2011 at 9:50
  • 1
    I've corrected the question, now the recommendation contains all the original information.
    – keiki
    Apr 14, 2011 at 9:57
  • The way to find what's active depends on your server. Some will be in the http.conf file, but others may be loaded dynamically. Do you have some sort of control panel, or do you have access to the server itself? Apr 14, 2011 at 12:19
  • It is a Wordpress website - so I guess it is an Apache server. I have FTP access to the website's files, access details to the LunarPages CMS and access to the Wordpress interface.
    – keiki
    Apr 14, 2011 at 14:01

5 Answers 5


If PHP is run as apache module, you can use the phpinfo() function. Search for the Apache section (usually apache2handler) and look for the row with "Loaded Modules":

apache2handler section of phpinfo()

  • 2
    Not listed on my shared hosting, unfortunately. Sep 17, 2015 at 11:58
  • 2
    @DjangoReinhardt It is possible that your shared hosting is not using Apache + mod_php, but instead nginx/Apache/... with php-fpm or even php-cgi. Look for the Server API line on top of the page (mine says FPM/FastCGI for php-fpm).
    – Lekensteyn
    Sep 17, 2015 at 19:53

Assuming you mean apache modules you can run the below to list which modules you have loaded:

apachectl -t -D DUMP_MODULES
  • 1
    -bash: apachectl: command not found sob :( Sep 17, 2015 at 11:56
  • You could try: find / apachectl | grep apachectl
    – dough
    Sep 17, 2015 at 18:43
  • 1
    ModSecurity: Failed to open debug log file: /var/log/apache2/modsec_debug.log then cat: /var/log/apache2/modsec_debug.log: Permission denied sob :( Feb 18, 2017 at 17:44

If you don't have those modules loaded then it doesn't look anything's going to break on your site, it's just not going to have the best cache control settings. So leave out the ifmodules as you can't even load them if they aren't loaded. The apache website says

In normal operation, directives need not be placed in sections.



First of all, please check on the server for all the different modules if they are enabled, and once they are, remove the <IfModule ...></IfModule>

About your query: you need to check whether those modules are enabled on server, and if they are you can remove the if condition from htaccess:

e.g. if module mod_expires.c is enabled then you can remove the <IfModule mod_expires.c></IfModule> and you'll keep only this part:

ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"

so you're not checking anymore to see if that module is enabled because you already did that.


1) just add to .htaccess

<ifModule mod_expires.c>
deny from YOUR.IP 


2) refresh your website
3) if you are out of game now, mod_expires is active
4) delete deny from YOUR.IP from ifModule mod_expires.c

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.