How to make mod_rewrite work on wamp

by krike in tips & tricks on 15 Nov 2009

I have been wondering for a long time now why mod_rewrite didn’t work on wamp and actually it’s quite easy even if I had to spend a lot of time searching.

In this quick tutorial I will show you how to make mod_rewrite work in wamp

First of all make sure the rewrite module is active on your wamp.

So right click on the wamp icon and go to apache->apache module and make sure rewrite module is checked


Now here is a small piece of my htaccess and of course it will only work on my live website, otherwise I wouldn’t be writting this article.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)/$ ./$1.php
RewriteRule ^tutorial/([0-9]+)$ /cmstut/view_tutorial.php?tutorial_id=$1 [QSA,L]

Now let’s make this work on wamp

As you can seeĀ  RewriteBase is set to / but my website on my wamp server is actually in the folder cmstut and not the root of wamp, so I need to change it to RewriteBase /cmstut/

next thing is to change the rewrite url from

RewriteRule ^(.*)/$ ./$1.php
RewriteRule ^tutorial/([0-9]+)$ ./view_tutorial.php?tutorial_id=$1 [QSA,L]


RewriteRule ^(.*)/$ /cmstut/$1.php
RewriteRule ^tutorial/([0-9]+)$ /cmstut/view_tutorial.php?tutorial_id=$1 [QSA,L]

of course replace cmstut folder name with your folder unless your site is in the root of wamp.
In that case I don’t think you need to change anything to your .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cmstut/#RewriteCond %{REMOTE_HOST} !^
#RewriteRule .* [R=302,L]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-fb

Written by krike

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet nisl nisl. Ut interdum libero vitae quam ultricies et lacinia elit aliquet. Praesent tincidunt, sem tempus feugiat feugiat, turpis tellus scelerisque erat, sit amet feugiat neque arcu ac lectus. Sed at mi et elit interdum scelerisque vitae eu felis.

krike has written 77 posts.

  • Dennis Perremans

    Just open the httpd.conf file on Wamp, Mamp or Xamp,…
    On Xamp you can find it on /etc/httpd.conf

    Find the “LoadModule rewrite_module modules/” line and delete the “#” symbol in front of it.
    # means that the line is a comment

    On Map you can find the file on /conf/apache/httpd.conf

  • That’s another way of doing it, especially for XAMP which doesn’t have the same menu system as wamp or mamp.

  • Johnny

    For virtualhosts, I changed this to fix my problem wich looked like a mod_rewrite problem at first:
    AllowOverride None to AllowOverride All

  • nesim

    you guys rock, my head was almost blowing only to find how simple it is to do this Mod_rewrite…thanks again its simple clear and super

  • Tushar Singh

    That srsly saved my day! THANKS!

  • I am using win7 x64 and I did this all thing but still is not working mod rewrite. šŸ™

  • jaya

    hey the rules above you mentions did not worked on wamp server if I changed the location name. its not redirecting at all. please explain how that rules actually works and redirects which url to what.

  • jaya

    i want to redirect http://localhost/redirecturl/member.php?id=1 to http://localhost/redirecturl/1 url. How to do that? thanks in advance.

  • Yogesh Jagdale

    Thank you very much!