Main Apache Directives

The main Apache configuration directives

The complete Apache directives list.


This directive sets the ip(s) and port on which the Apache server listens for connection.


Instead of the actual IP must be used. Port 80 is the regular http port and 443 is the default https port. If the server has multiple interfaces (phisical or virtual) the * character must be used to cover all IPs.

Listen *:80

User / Group

These directives set the user and the group under which the http server will be running.


This sets the name of the server reported by Apache.


This sets the locations of the server and all its files. All paths from httpd.conf will be relative to this path.


This is the WebSpace. This is the location where Apache will search for the files and folders requested by the clients.


This sets the default file served by Apache if the client has not requested a specific file. For this to work the dir_module must be loaded.

LoadModule dir_module modules/

<IfModule dir_module>

DirectoryIndex index.php index.htm index.html



This generates a folder’s index if there’s no file matching the options in DirectoryIndex. It needs the autoindex_module.

LoadModule autoindex_module  modules/

IndexOptions   FancyIndexing FoldersFirst


It needs the autoindex module (

IndexIgnore *.jpeg


This is used to map an URL or local directory to a location outside the document tree. It requires the module.

LoadModule alias_module

Alias /var /path_outsite_document_tree

There is a variant to this called ScriptAlias used for folders with CGI scripts.


This is similar to Alias but it’s used to map a resource from local Webspace to a remote one.

Redirect /dir


This sets the logging options. Some possible values for LogLevel: debug, info, notice, warn, error, crit, alert, emerg.

ErrorLog /log_path

LogLevel warn


This sets specific answers of the server in case of an specific errors (either as a message or as path to a file).

ErrorDocument  500  “Error message”

ErrorDocument  404  /error.html

Incomplete list of error numbers:

400 Bad Request – HTTP_BAD_REQUEST
401 Authorization Required – HTTP_UNAUTHORIZED
402 Payment Required – HTTP_PAYMENT_REQUIRED
403 Forbidden – HTTP_FORBIDDEN
404 Not Found – HTTP_NOT_FOUND
405 Method Not Allowed – HTTP_METHOD_NOT_ALLOWED
406 Not Acceptable – HTTP_NOT_ACCEPTABLE
407 Proxy Authentication Required – HTTP_PROXY_AUTHENTICATION_REQUIRED
408 Request Time-out – HTTP_REQUEST_TIME_OUT
409 Conflict – HTTP_CONFLICT
410 Gone – HTTP_GONE
411 Length Required – HTTP_LENGTH_REQUIRED
413 Request Entity Too Large – HTTP_REQUEST_ENTITY_TOO_LARGE
500 Internal Server Error – HTTP_INTERNAL_SERVER_ERROR
501 Method Not Implemented – HTTP_NOT_IMPLEMENTED
503 Service Temporarily Unavailable – HTTP_SERVICE_UNAVAILABLE


This is used to set some options for a specific directory from the Webspace and it can only be used as a core setting (not in .htaccess).

<Directory /path>

Options Indexes FollowSymLinks      # example 1

AllowOverride ALL                                  # example 2


If AllowOverride is set on None, Apache does not even read .htaccess.


This directive is used to restrict access to certain files. This can be used in .htaccess and regular expressions can be used.

<FilesMatch “^\.ht”>

Order allow,deny

Deny from all



This is equivalent to FilesMatch but the regular expression must be preceded by ~

<Files ~ “\.(gif|jp?g|png)$”>

Order allow,deny

Allow from



Associate a server action with the file type requested by the client. This required

LoadModule mime_module /modules/

DefaultType text/plain

TypesConfig conf/mime.types