Enable .htaccess and url rewriting in Apache for Windows
When I try to setup PHP and Apache in my notebook, I try to enable the .htaccess setting in apache's httpd.conf. After I tried for a few hours (YES, a few hours) at my notebook and google-ing on the internet, finally I found the complete solution.
I record the steps here so that it can help those who want to enable .htaccess and url rewriting in Apache for Windows and also for my own reference in future.
1. Make sure you have setup apache and php correctly. Make sure that you can run php scripts without any problem.
2. Use notepad to open httpd.conf config file. Make use the line "LoadModule rewrite_module modules/mod_rewrite.so" is un-commented.
3. Under "<directory XXX></directory>" section, change the line "AllowOverride None" to "AllowOverride All".
4. Change the line "AccessFileName .htaccess" to "AccessFileName htaccess". This is because in Windows, we can't have a file with filename that starts with a dot.
5. Save the changed file and restart Apache Windows Service. You can then use the file htaccess to process your url rewritting.













July 24th, 2006 - 01:27
nice howto, bookmarked :)
September 1st, 2006 - 06:23
Bravo! Worked like a charm. Thanks.
November 10th, 2006 - 22:46
Thank you for saving me those countless hours :)
November 26th, 2006 - 07:53
Brilliant! Thank you!!
August 2nd, 2007 - 19:50
Thanks to szehau….
:)
April 9th, 2008 - 23:56
you can create “.htaccess” file by using notepad(save as .htaccess file) in windows :)
April 16th, 2008 - 15:51
Thank you very much.
the solution what u have given above is amazing.
April 26th, 2008 - 15:43
I try to follow steps that you showed on my laptop but it doesn’t work at all. You mentioned about
4. Change the line “AccessFileName .htaccess” to “AccessFileName htaccess”.
I am using wamp and don’t see anywhere in the httpd.conf file have that statement. Where should I put it in the httpd.conf?
Thanks for your help
April 27th, 2008 - 10:55
Hi Vuong Ho, you can try put the line to the end of the httpd.conf file or any place in the httpd.conf file (but not between and tage).
September 20th, 2008 - 17:31
Hi,
I couldnt find httpd.conf file in my server…can u help me can we write manually httpd.conf file…
Thanks
Developer
September 20th, 2008 - 18:06
Hi, you get a sample configuration from apache.. just download the full package from apache and use the httpd.conf in the package.
October 17th, 2008 - 14:43
The solution is given is amazing and solved my problem after a lot of search in the internet.Thanks
October 19th, 2008 - 06:02
Hi Sarwar Zahan, you are welcome.
January 15th, 2009 - 04:19
Worked for me too…
May 26th, 2009 - 17:19
Brilliant solution, but in order for the thing to work 100% you need to add
Order allow,deny
Deny from all
Satisfy All
into httpd.conf file.
and change names of all the “.htaccess” to “htaccess” in all the directories on the website.
thank you for pointing me out to right direction.
May 27th, 2009 - 22:16
Thank you too, Andrei.