Change WordPress Permalink Structure and Manage Redirection on IIS

Wordpress Permalink Change and RedirectionA lot of us start our wordpress blogs with the default permalink structure and realize changing to pretty permalink format has better benefits. Usually wordpress blogs hosted on either Linux or IIS based servers. On the internet I have found lot of posts about how to configure the permalinks and manage redirection on the linux or apache based servers.

But I had tough time finding the right information about how to manage the permalink changes and redirections after that on IIS based servers. So I am covering the complete workflow based on IIS server here.

If you google about wordpress permalink change on IIS, you would probably end up in to wordpress codex page – http://codex.wordpress.org/Using_Permalinks#Permalinks%5Fwithout%5Fmod%5Frewrite

The .htaccess configurations explained in this page is not related to IIS servers at all. This is applicable only for Linux servers. Making changes to this file has no impact on IIS (unless the IIS server uses Apache to run PHP which is very rare).

This page explains a lot about achieving pretty permalinks on IIS. But if you have your blog hosted on any of the modern IIS servers they must be preconfigured for most of the settings explained on this page such as URL rewrite.

So assuming you have a modern server already, you can just visit the WordPress admin panel > Settings > Permalinks and change the Permalink settings shown below.

Here choose the ‘Post Name’ option or a custom structure of your choice. But hold on to saving your change for a moment and continue reading this post completely.


Wordpress Permalink Settings Change

WordPress Permalink Settings Change


Before you make this change there is a small pre-work. What would happen to your older links? The search engines would be still referring to your previous links for a while and many other links you have shared with others and social sites will no longer work. That is a big trouble.

To tackle this situation, you will have two options.

Option 1 – Edit the web.config file and add redirection code in it. But after many attempts I have figured out that this option is not reliable and very complicated to configure. So I am not going to explain this option in-detail.

Option 2 – Add the wordpress Redirection plug-in to redirect all your previous post links to the new links. So, all your old links will not break.

  • First install and activate the Redirection plug-in
  • After the activation visit the plug-in settings page
Wordpress Redirection Settings

WordPress Redirection Settings


Now here is the tricky part. You will have to build some redirection URLs with the help of regular expressions carefully.

  • First check the Regex checkbox
  • Now you will have to build the Source and Target URLs for the redirection

Refer this table below for samples and build the Source/Target URLs links based your site:


If your current blog uses

Source URL

Target URL

Default format as – http://www.myblog.com/?p=123

You don’t need this plug-in at all. You are good to go!

Day and Name format as –




Month and name format as –




Numeric format as –




If your blog hosted in a sub-folder like http://www.mysite.com/blog/ then you can still refer the table above but insert your folder name at the beginning of source URL like ^/blog/archives/(\d+)$ in the table above

Now enter this Source URL and Target URL values (don’t forget to check RegEx checkbox). Leave the drop down options to defaults.

Now press the Add Direction button so the redirection would be activated.

Now quickly get back to the Permalink settings page and change the permalink option I have explained above as per your preference (either ‘Post Name’ or a custom structure) and save the changes.

You should be all set now. All your current blog links would change to your new structure and all your previous links would be redirected to the new links.


Some Additional Background (for techies’ satisfaction!)

If you are wondering about the ‘tricky’ codes added for the source URL field above, they are called regular expressions. Regular expressions are executable piece of codes that applications can interpret for validation purposes.

Let’s take this example for Source URL,

Month and name format as –



^ – symbol works like placeholder for representing the beginning of URL in other words could be equivalent for http://myblog.com or any other link in that place

([0-9]{4}) – This code represents a 4 digit number in the URL

([0-9]{2}) – Similarly this code represents a 2 digit number

(.*) – Represents character sequence that means any combination of alpha numeric

$ -Represents the end of link, so the link assumed to end here


For Target URL,


$3 -$3 in this target URL represents the 3rd variable captured from the inbound link and used for your destination (redirected) URL

So we are essentially building a conditional expression that the Redirection plug-in can interpret and validate the inbound links and when the condition matches it builds the redirection link and calls them instead. So none of your old links break!



  1. Alex says:

    Nice write-up. How about from /%year%/%monthnum%/%day%/%postname%/ to /%category%/%postname%/ ?

    So from date to category? Can’t really be accomplished with regex and I don’t think the plugins will support passing variables?

    1. electron says:

      Hey there, thank you for your comment.

      Your case not seems to be very unusual. I think the following parameters with the redirection plugin could work for you:

      Source URL: ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+)/$
      Destination URL: http://www.yoursite.com/%category%/$4

      Here the $4 is the variable captured from your source link equivalent to your /%postname%/

  2. Joseph Nirmal says:

    I want to change permalink from /%postname%/ to /%year%/%month%/%postname%/

    1. electron says:

      Hey Joseph, you can try the redirect

      Source URL: ^/([0-9]{4})/%month%/([^/]+)/$

      Destination URL: http://myblog.com/$2

      Replace http://myblog.com with your URL

  3. My Own Advisor says:

    What happens when you add http://myblog.com/$4 and this breaks the Monthly Archive link?

    Meaning, the Monthly Archives now get redirected to the homepage?

    Is there a fix for that?


Leave a Reply

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=""> <strike> <strong>