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 “
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.
nice howto, bookmarked :)
Bravo! Worked like a charm. Thanks.
Thank you for saving me those countless hours :)
Brilliant! Thank you!!
Anoop Kumar says
Thanks to szehau….
you can create “.htaccess” file by using notepad(save as .htaccess file) in windows :)
Kailash Kumar P says
Thank you very much.
the solution what u have given above is amazing.
Vuong Ho says
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
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
I couldnt find httpd.conf file in my server…can u help me can we write manually httpd.conf file…
Hi, you get a sample configuration from apache.. just download the full package from apache and use the httpd.conf in the package.
Sarwar Zahan says
The solution is given is amazing and solved my problem after a lot of search in the internet.Thanks
Hi Sarwar Zahan, you are welcome.
Worked for me too…
Brilliant solution, but in order for the thing to work 100% you need to add
Deny from 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.
Thank you too, Andrei.
Prabhakar Kasi says
Hello. Thanks for documenting the steps. I read same solution in different websites but luckily things worked after reading you website. LUCKY!!!