-

Apache Quick Tips

Ensure AllowOverride on htaccess is enabled

A very powerful way apache allows to customize web sites is through .htaccess files

Make sure that the AllowOverride is enabled (AllowOverride all) in httpd.conf hecause many distribs have default as none)

if it is not that, you may have to post the actual htaccess for more help

RedirectMatch 404

With the increasing number of spiders looking for vulnerabilities, it is useful hide directories to make sure they are not accessible.

For example, if you wanted to hide the a git directory, you would do the following:

RedirectMatch 404 /\.git
RedirectMatch 404 /\.gitmodules

With that said, it is even better if the git directory is not even there

Redirect all pages to a single script

While parameters are useful and functional, many times you want your script to get all pages of a web site to make more SEO Friendly URLS. A good way to do that is through rewrite rule.

Here is an example sending everything to index.php:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]

Another example is migrating by redirecting pages:

RewriteRule ^items\-(.+)_(.*)_(.*).html /store/$1/$2/$3.txt    [L,NC,R=301]  
RewriteRule ^categories-(.+).html    /store/category/$1       [L,NC,R=301]