Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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

<IfModule
 ...></IfModule>

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>

<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>

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

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

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

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

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

<ifModule mod_headers.c>
  Header unset ETag
</ifModule>

FileETag None

<ifModule mod_headers.c>
  Header unset Last-Modified
</ifModule>

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

</IfModule>
# END WordPress
share|improve this question
    
I think you need more information from the person who said that. What modules? Apache modules? What do they mean by "blocks"? –  paulmorriss Apr 14 '11 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 '11 at 9:50
1  
I've corrected the question, now the recommendation contains all the original information. –  keiki Apr 14 '11 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? –  paulmorriss Apr 14 '11 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 '11 at 14:01
show 1 more comment

4 Answers

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

apachectl -t -D DUMP_MODULES
share|improve this answer
add comment

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()

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

http://httpd.apache.org/docs/2.0/mod/core.html#ifmodule

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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