Change WordPress Permalink Structure With IIS 6 Server

WordPress Permalink structure is important with respect to the Search Engine Optimization (SEO). I observed that most of the WordPress blogs have a Permalink Structure which looks like /index.php/%postname%/. This post will help you to change your permalink structure using the Microsoft IIS 6 server.

  1. Create a “php” file, say ‘404_wp.php’, paste the below code and upload it to your wordpress root folder (i.e., in same folder/directory where “wp-config.php” file is located.
  2. <?php
    // Default file for WordPress site, generally "index.php"
    $wpdefault = 'index.php';
    // The name of this file.
    $tempfile = '404_wp.php';
    $_SERVER['SCRIPT_FILENAME'] = str_replace($tempfile, $wpdefault, $_SERVER['SCRIPT_FILENAME']);
    $_SERVER['ORIG_PATH_INFO'] = str_replace($tempfile, $wpdefault, $_SERVER['ORIG_PATH_INFO']);
    $_SERVER['SCRIPT_NAME'] = str_replace($tempfile, $wpdefault, $_SERVER['SCRIPT_NAME']);
    $_SERVER['PHP_SELF'] = str_replace($tempfile, $wpdefault, $_SERVER['PHP_SELF']);
    $_SERVER['PATH_INFO'] = false;
    $querystr =& $_SERVER['QUERY_STRING']; $requesturl =& $_SERVER['REQUEST_URI'];
    $position = strrpos($querystr, '://');
    $position = strpos($querystr, '/', $position + 4);
    $_SERVER['URL'] = $requesturl = substr($querystr, $position);
    $querystr = trim(stristr($requesturl, '?'), '?');
    // Required for WordPress 2.8+
    $_SERVER['HTTP_X_ORIGINAL_URL'] = $requesturl;
    // Fix GET vars
    foreach ( $_GET as $var => $val ) {
    if ( substr($var, 0, 3) == '404') {
    if ( strstr($var, '?') ) {
    $nv = substr($var, strpos($var, '?') + 1);
    $_GET[$nv] = $val;

  3. Download and Install Internet Information Services (IIS) 6.0 Manager for Windows XP from Microsoft Site. Alternatively, you can install this from your Windows XP Installation CD.
    Download Link
  4. Go to your Windows Control Panel -> Administrative Tools and open Internet Information Services (IIS6) Manager
  5. Right click Internet Information Services and select Connect
  6. “Connect to Computer” dialog box will open, enter your IIS 6 Server IP Address, and Login Credentials
    (In case, you can’t find the IP Address, you can open Command Prompt from Start Menu and ping your site to find IP Address) i.e. ping

  7. Click OK, so as to connect to your server. The IIS manager will open as shown below.
  8. On left-hand side navigation, click on [+] before Your Server’s IP Address to expand
  9. Click on [+] to expand Web Sites
  10. Right click the name of website on which pretty permalinks need to be enable, and select Properties, which would open the Properties dialog box.
  11. Select Custom Error tabs, and find 404 from the grid.
  12. Click Edit button, you will be greeted by another dialog box. Select “URL” from Message Type Drop-Down, and for URL field, write relative path to “404_wp.php” file, that you have created and uploaded on your server (in step 1) and click OK.
  13. You can see the new “404” URL in Custom-Error Tab Grid. Close the dialog-box.
  14. Right click the web-site that you have connected to and select Disconnect and then close the Internet Information Services (IIS6) Manager
  15. Login to your WordPress Admin-Panel and change your permalink structure to  /%postname%/ or any other structure as shown below.

This is how you can easily change your permalink structure using the Microsoft IIS server for a good SEO for your blog. Do write your feedback through your comments.

21 replies on “Change WordPress Permalink Structure With IIS 6 Server”

  1. I try to do everything you said but still not work with my web site
    You have any idea to help me fix permalink problem with out index.php
    Please tell me step by step I use window server IIS6 PHP 5.2.13 wordpress version 3.1
    Thank you

    1. Please cross check in WordPress admin section under Settings->General, if there is index.php URL is present then remove that. Hope it may help you.

    1. You need to write some php code into index.php of your WordPress root. str_replace() function to replace the current URL of that is in browser with index.php URL.
      I am not sure without looking into your WordPress files and hosting server , but hope the below code will work fine. Add this code in index.php

      function strleft($s1, $s2) {
      return substr($s1, 0, strpos($s1, $s2));
      function selfURL(){
      $serverrequri = $_SERVER['PHP_SELF'];
      $serverrequri = $_SERVER['REQUEST_URI'];
      $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
      $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
      $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
      return $protocol."://".$_SERVER['SERVER_NAME'].$port.$serverrequri;
      $current_url = selfURL();
      if (strstr($current_url, '/index.php/')) {
      $current_url = str_replace('/index.php','',$current_url);

  2. Hi..Thank you for reply I put your code on my index.php already after that i go to change my permalink but still show 404 error not found,I use window 2003 IIS 6 PHP 5.2.13 wordpress version 3.1 VPS plan Plesk Panel ixwebhosting I don’t know what to do because they not have mod_rewrite and not accept 3 party software but i have ASP.NET Configuration for Domain you think i will setting something on or not? I don’t know Please help.

    1. Some assumptions :
      1) Hope you added above given code in comment into index.php file, just above the previous code that already present in index.php.
      2) you have already created 404 file says 404_wp.php file and now following all the steps as mentioned in this post.

      If these above points are correctly done by you then it should work for your blog. I cannot suggest you exact solution, without looking into your server. You can avail our services to solve the above problem. Contact us

    1. Yes,
      But I cannot see any index.php in your blog post permalink, and most of the links are working fine, so where you are getting problem?

  3. Hi
    my website
    here on my permalinks section permakinks example displays
    this type of link.
    I move my content from a site to this site.
    Now my problem is if i want use this type of permalink
    its not working. but is woking.
    How ca i do that in IIS 6 Server

    1. Hi Shalf,
      This post is showing how to remove index.php section from permalink structure, you need to follow all the steps given in this post. And it will work fine.


  4. Hi, thank you for your greate tutorial. But i have a problem with it.
    Parse error: syntax error, unexpected $end in C:Inetpubvhostsdomainhttpdocsblog404_wp.php on line 29

  5. No need to install any ISAPI filter to remove the index.php from WordPress permalinks.No need of .htaccess file..Use these simple steps to WordPress Permalinks in IIS 6.0 using Custom 404 Redirect for Windows Shared hosting/manas hosting or any windows shared hosting.

  6. I put a bracket after break in last lines and now it is working with another error.

    Warning: strpos() [function.strpos]: Offset not contained in string in C:\Sites\webroot\pro\404_wp.php on line 26

Comments are closed.