Weblog
Thoughts which doesn't affect the world's peace

Apache2, .htaccess, mod_rewrite

In apache2 you can’t use .htaccess files by default. That’s just fine, security-wise, but not if you really need to use them.
In the general case, you should put your mod_rewrite or any other .htaccess rules in your httpd config (if you have access to it).
If you need to add mod_rewrite rules to a .htaccess file, you should look for the following:

  1. Make sure that you have the mod_rewrite installed.
  2. Make sure your mod_rewrite is enabled in your httpd.conf file
    You could do that by opening your httpd.conf and look for line like this:

    LoadModule rewrite_module modules/mod_rewrite.so

    Make sure there is no comment signs in front of it.
    (Note: the above are installed by default in Fedora 11+)

  3. In your httpd.conf look for the following line:
    AllowOverride None

    and change it to

    AllowOverride All

    There should be two of them – one for “Directory /” and one for “Directory /var/www/html”.

  4. If you need to change the default charset of your webserver, look for the following line in the httpd.conf
    AddDefaultCharset UTF-8

    Replace UTF-8 with your desired charset.
    If you want to control the charset with meta tags from your web documents, you should comment the line.

  5. When you are done editing, you should restart the webserver first, before attempting to see the results.

Tags: , ,

Comments are closed.