Enabling mod_rewrite on Windows Apache for URL rewriting

06 April, 2013 by Tom Elliott

These steps should help enable the mod_rewrite apache module for anyone running a local WAMP stack – Apache, MySQL & PHP on a Windows machine.

I needed to do this with a local WordPress website which was setup to serve a number of friendly URLs using the .htaccess file. As the mod_rewrite module was not enabled, this prevented the .htaccess file from doing any URL rewriting, causing an error 404 page not found error on the WordPress site.

To enable mod_rewrite, I went through the below steps:

  1. Find and open the file .http.conf. This will be located in your Apache install folder. For me, the full path was C:Program Files (x86)Apache Software FoundationApache2.2conf
  2. Make a backup of http.conf which you can restore from, if anything were to go wrong
  3. Find the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the hash ‘#’enable-mod-rewrite-1
  4. Locate the block within the directory tags as indicated below and change to:
    <directory />
    Options All

      AllowOverride All
    </directory>
    enable-mod-rewrite-2
  5. Find any additional occurrences of the line “AllowOverride None” and change it to “AllowOverride All”.
  6. Finally, restart apache server and your browser. The .htaccess rewriting should now be working for any local website or WordPress install instead of displaying the page not found error.
    restart-apache


33 Comments

  • Raul says:

    Thank you!

  • Lysle says:

    I’ve been looking for a way to update the .htaccess file for a while, and now it works !!!
    Thank you very much for your article !
    Kindest regards from France

  • Thanh The says:

    Thank you so much!

  • Keme says:

    I made the changes accordingly in httpd.conf but the wamp server wont restart.
    Please help.

  • Leandro says:

    You save my life!
    Thanks a lot!

  • Adriano Faria Alves says:

    Thank you!

  • Sanwal Farooque says:

    Thankyou So much I have been searching for a long time.
    You are a life saver 🙂

  • Andrew says:

    Didn’t work. Still getting the error.

  • James says:

    This really helped me, thanks!!

  • james says:

    Many thanks. Your explanation helped me a lot

  • Paul says:

    Thanks, Worked Well!

  • ramprasanth says:

    Thank you. Nice Explanation

  • Nina says:

    Life saver!

  • Terrysharp says:

    Hello from France,
    Just a question.
    Does all the rewriting types running ??
    i m looking for rewrite a dynamic url to a static url and it doesn’t work !!

    Any solution ?
    Best regards
    Terry

  • Daniel Lugo says:

    This save my life:
    5. Find any additional occurrences of the line “AllowOverride None” and change it to “AllowOverride All”.

    Thank YOU!!!

  • joshi says:

    Thank you its really helped me.

  • ajay says:

    Very nice

  • Thiha says:

    Thank you so much.

  • naroth says:

    thank you !!!

  • mark says:

    Thanks Bro!!

  • Srinivas says:

    Thank you. it is very useful info

  • Eric Y says:

    Thanks a lot! TOM!

    And, for my experience, you need to edit
    1. Option
    2. AllowOverride
    for

    as well~

  • Marc says:

    Apache wont restart after doing this… any fix suggestions?

  • rahman says:

    thanks, alhamdulillah

  • datta says:

    Dude,This is fine with the windows users.
    I am using Ubuntu 15.10.In my apache2.config there is no line that you have mentioned above.When I did the rest changes I am getting an internal server errror

  • Dave Gerrard says:

    Just to add to this – it works fine, but if you’re doing this for WordPress (like I was), you don’t have to edit AllowOverride to All everywhere. It only needs to be set for the Directory that your WordPress files are in.

  • Robert says:

    Thank you.

    About “AllowOverride All”, should suffice to set it for the document root directory.

  • Thejas says:

    Thank you for the clear and detailed explanation

  • fatiz says:

    thank you bro you re a saver

  • Ali says:

    Thanks. Saved me.

  • Gaurav says:

    Thanks, It works:)

  • Spirol says:

    Thank you, still works ;D