Posted on November 15th, 2009 in tips & tricks
How to make mod_rewrite work on wamp
How to make mod_rewrite work on wampI 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]
</IfModule>
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]
to
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
RewriteEngine on
RewriteBase /cmstut/#RewriteCond %{REMOTE_HOST} !^81\.165\.9\.219
#RewriteRule .* http://www.iv-designs.org/maintenance/maintenance.html [R=302,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-fb
Delicious
Digg this
Stumble it
Tweet this





Search
Stay in touch
Write something for us!
Most commented posts
Categories









Wordpress top tutorials
Dynamic website using php – part 1
Basic nuke chrome theme
Comment by Dennis Perremans on November 29, 2009 at 12:35 am
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/mod_rewrite.so” 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
Comment by krike on November 29, 2009 at 10:30 am
That’s another way of doing it, especially for XAMP which doesn’t have the same menu system as wamp or mamp.
Leave a reply: