Test Your Custom Permalinks On Local WordPress Installation In Windows [Windows Mod Rewrite]

If you run WordPress on your local PC, chances are that you may not be testing it using custom permalinks, you may have on your actual website, the reason being that your default Apache configuration may give you 404 errors when you try to use custom permalinks.

apache-mod-rewrite-windows

This is because, a Apache installation on windows does not have mod_rewrite enabled by default. So if you are looking to test your custom permalinks on your local WordPress installation in Windows, you will have to enable it in the Apache configuration file (httpd.conf). Here are the directions on how you can do that.

Related: Creating SEO Friendly URLs using Mod Rewrite and PHP


Enabling Mod Rewrite On A Standalone Apache Server

There are several bundled packages that install Apache, MySQL and PHP with a single installation, but if you have installed stand alone copies of Apache, here are the instructions to enable mod rewrite on a standalone apache server installation.

Step 1: Navigate to Drive:\Apache Install Dir\conf folder, replace drive with the actual drive apache is installed in and the Apache Install Dir with the path to the Apache installation.

Step 2: Open the file named httpd.conf, and search for the text mod_rewrite, once you find the text, delete the #at the beginning of the line and save the file. The #in the configuration file symbolizes a comment.

enable-mod-rewrite-in-standalone-windows-apache-installations

Step 3: Save the httpd.conf file and restart Apache, once the changes have been made, go to your WordPress dashboard in your local installation and change the permalinks to use the custom URLs, you use on your live website.

Enabling Mod Rewrite In WampServer

If you use WampServer to run a test environment on your local PC, adding mod rewrite capabilities is fairly simple.

Step 1: Click on the Wampserver icon in the system tray and navigate to Apache.

Step 2: In the available sub-menu options, hover you mouse over Apache modules and navigate the module list till you find rewrite_module and click on it.

enable-mod-rewrite-in-wampserver-installations

Step 3: Once you have selected the option, wampserver will automatically restart the servers for the change to take effect. Once it has restarted, go to your WordPress dashboard in your local installation and change the permalinks to use the custom URLs, you use on your live website.

Enabling Mod Rewrite In XAMPP for Windows

If you are using XAMPP for Windows, which is another popular bundled test environment for a Windows PC, here are the instructions to enable mod_rewrite in Windows.

Step 1: Navigate to the XAMPP installation folder and open the apache\conf directory.

Step 2: From here you need to follow the steps as discussed in the standalone Apache instructions to uncomment the mod_rewrite in httpd.conf file

Step 3: Click on the XAMPP icon in the system tray and stop and start the Apache server. Once it has restarted, go to your WordPress dashboard in your local installation and change the permalinks to use the custom URLs, you use on your live website.

Hopefully enabling the mod_rewrite in your local test installations, will help you test your changes as you would see it on a live website.

9 thoughts on “Test Your Custom Permalinks On Local WordPress Installation In Windows [Windows Mod Rewrite]”

    1. If you go to the wordpress admin panel under “Settings->permalinks” change the permalinks style to “custom” and write “/%postname%/” (without the quotes) and save the changes. WordPress will create the .htaccess file for you in your wordpress root.

  1. The only problem is that I’ve enabled it and it still doesn’t work. There must be some kind of trick to this. And before you ask, yes, I uncommented the line, and yes the module is there, and yet I’ve restarted. The instructions are so easy there’s no way to mess them up. So why won’t it work?

  2. Hi, thanks a bunch for your instructions. I uncommented loading the rewrite module. I copied a well functioning WordPress site to my localhost, everything works except for the page that with the url http://localhost/wp/products-page/ and the other similar ones. I am kind of new to WP, is this about permalinks or somthing else? I feel like it is a Apache setup as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>