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.

Share this article

  • digg
  • del.icio.us
  • Fark
  • Furl
  • Spurl
  • BlinkList
  • YahooMyWeb
  • Simpy
  • blinkbits
  • Digg
  • Facebook
  • Google
  • Live
  • Technorati
  • blogmarks

11 Responses to “Enable .htaccess and url rewriting in Apache for Windows”

  • mypapit
    July 24th, 2006, 1:27 am

    nice howto, bookmarked :)

  • Nemanja
    September 1st, 2006, 6:23 am

    Bravo! Worked like a charm. Thanks.

  • SubZane
    November 10th, 2006, 10:46 pm

    Thank you for saving me those countless hours :)

  • Ryan
    November 26th, 2006, 7:53 am

    Brilliant! Thank you!!

  • Anoop Kumar
    August 2nd, 2007, 7:50 pm

    Thanks to szehau….
    :)

  • winxp
    April 9th, 2008, 11:56 pm

    you can create “.htaccess” file by using notepad(save as .htaccess file) in windows :)

  • Kailash Kumar P
    April 16th, 2008, 3:51 pm

    Thank you very much.
    the solution what u have given above is amazing.

  • Vuong Ho
    April 26th, 2008, 3:43 pm

    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

  • szehau
    April 27th, 2008, 10:55 am

    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).

  • Developer
    September 20th, 2008, 5:31 pm

    Hi,

    I couldnt find httpd.conf file in my server…can u help me can we write manually httpd.conf file…

    Thanks
    Developer

  • szehau
    September 20th, 2008, 6:06 pm

    Hi, you get a sample configuration from apache.. just download the full package from apache and use the httpd.conf in the package.

 

Leave a Reply