For some people it’s a hard job to configure their Windows machine using Apache for mod_rewrite. But in fact this is not a hard process.

Let’s check the steps together.

You know that most of things are modules in Apache. By default mod_rewrite is closed on most Apache versions. So you need to open usage of this module.

Now open httpd.conf ( this file is on your Apache installation directory, in a sub directory called conf ). Search for these lines :

#LoadModule rewrite_module modules/mod_rewrite.so
..
#AddModule mod_rewrite.c

After finding them remove the sharps before them. This will make mod_rewrite usable.

After doing this you need to give htaccess files the right to manipulate codes. Search for httpd.conf something like this :

<directory "C:/Inetpub/Your_Root_Dir">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</directory>

You can clearly see that AllowOverride option is set by None. If this options remains like that you’ve no ability to manage URL’s from htaccess file. So you must change it. Changing it to All will help almost like this : AllowOverride All

After doing these you can feel free to restart apache service :

net stop apache
net start apache

Now you can use htaccess files to manage your url’s using mod_rewrite module.

Tiny Tip For Htaccess Usage :

In Windows systems to create files without name (for example .htaccess) is not possible with windows explorer. Sure, you can create this kind of files from command line (cmd.exe). But it’s not a good solution for some.

So, you can change the file name of the apache user configuration file by changing a directive in httpd.conf. That directive is AccessFileName directive. Search for this and you see that .htaccess is set to this directive like this : AccessFileName .htaccess. Now change it to a filename which has a name like this AccessFileName my.htaccess. Then restart your apache.

Now you can use my.htaccess file to change settings from user controlled apache configuration files.

For Detailed Information :

  1. Apache mod_rewrite Guide
  2. Apache mod_rewrite Manual
Tags: , ,
Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>