Introduction

This page contains useful configuration hacks for the Apache HTTP Server.

Hide your scripting/parsing technology

If you're using server-side scripting or includes to generate web pages dynamically, you can make it look like they're normal HTML pages. The following assumes your dynamic pages have names ending in .php.

Convince your web server that when someone requests a .html file that doesn't exist, it should try for a .php file instead.

    RewriteEngine on
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} ^(.*)\.html$
    RewriteCond %1.html                             !-f
    RewriteCond %1.php                              -f
    RewriteRule ^(.*)\.html                         $1.php [L]

This causes a redirect to occur that is internal to the server, so the browser never knows that it is being tricked. The [L] on the last line says that this is the last rewrite to occur, but you mightn't want this. You can use this for multiple types of dynamic pages by repeating the last 4 lines and changing .php to a different suffix.