httpd.conf file

On Apache servers, the httpd.conf file is the main file of concern when modifying settings and functionality.

Depending on the hosting package and provider you chose, you may or may not have access to this file to modify. You may also have access to make limited changes via a graphical control panel. The default settings of your hosting package will dictate which, if any, changes might be needed. Changes I have had to make at different times include:

Recognize index.php as the default server page

You probably already know that when you type in a web address you don’t need to specify /index.htm, /index.html, etc. That is because the server is usually configured to recognize .htm* files as default. You would think that when you add the PHP service to your server it would automatically recognize index.php as a default page as well. Usually that will be the case. But, for some hosting providers (e.g., mine) you must specify this yourself. To do so, find the following line in httpd.conf:

DirectoryIndex index.html index.htm

and replace with:

DirectoryIndex index.php index.html index.htm

Note: If you don’t have access to the httpd.conf file you can make this change via a .htaccess file. To do so, just add the following line:

DirectoryIndex index.php index.htm index.html

404 page customization

If you can modify you httpd.conf file, find the line that begins with:

ErrorDocument 404

And change what comes after the 404 to the page location you wish your 404 pages to be redirected, e.g.,

ErrorDocument 404 /dirname/404page.php

If you don’t have access to the httpd.conf file you can make this change via a .htaccess file. To do so, just add the following line:

ErrorDocument 404 /dirname/filename

Log file format

Your server tracks all site access and records relevant details to log files. The amount and format of information logged can be changed via the httpd.conf file. The point of this is to provide raw data for site analytics software. Thus, the only time you will really care about this is if you plan to install analytics software on your server. These days, many people are choosing hosted analytics programs like Google Analytics, which require placement of code on every relevant page, thus allowing logging directly to the hosted software site. In such a case, you don’t care too much about log file format. If you want to know more about changing your log file format, I recommend reading the relevant Apache page.

Directory access

Some default server setups allow anyone to see contents of a directory where there is no index file. You may have seen this on other sites before where instead of a webpage you just saw a list of folders and filenames. Generally, this is not something you want. To make sure this doesn’t happen on your server, comment out the following line in your httpd.conf file (e.g. add a # before the line).

Options Indexes FollowSymLinks MultiViews Includes

Like this content? Why not share it?
Share on FacebookTweet about this on TwitterShare on LinkedInBuffer this pagePin on PinterestShare on Redditshare on TumblrShare on StumbleUpon

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.