WordPress URL Rewrites for Windows IIS – How to Remove index.php Using HTTPD.ini file

divider

WordPress can be run on a Windows server and runs well. The only issue is the PESKY PESKY index.php that appears in the URL path.

If you have Helicon’s ISAPI Rewrite installed (which you should if you are running a Windows server) with the HTTPD.ini file, then simply add in this code to the httpd.ini file:

#Rewrite wpcontent path (stylesheet, images, admin)
RewriteRule /blog/wp-(.*) /blog/wp-$1 [I,L]

#Removes index.php
RewriteRule /blog/(.*)$ /blog/index.php/$1 [I,L]

Pretty easy. The first line of code allows all your CSS, images, and admin to work. The second line of code removes the index.php. It works and that is all the is needed to get rid of /index.php in the file path.

Two notes:

1. Our permalink path in WordPress is /%postname/. Just change that to whatever you need.
2. Our blog directory is called /blog/. Just change that to whatever you need.
3. If the above does not work for you, try this line of code too: RewriteRule /blog/(.*)$ /blog/index.php\?/$1 [I,L]


14 Responses to WordPress URL Rewrites for Windows IIS – How to Remove index.php Using HTTPD.ini file

  1. Chris
    9:56 am on August 18th, 2009

    Can you elaborate on the blog directory? I am just trying to figure out what exactly I need to change ours to in order to make this work. Thanks.

  2. Peter
    10:25 am on August 18th, 2009

    Sorry, I do not know what you mean by elaborate? Our blog (this one) is under https://www.paperstreet.com/blog/. So the HTTPD above is the code to use for removing index.php from the URL and just have /blog/

  3. Chris
    12:17 pm on August 18th, 2009

    I followed the procedure but get a 404 when I remove index.php from the permalink address. So it either doesn’t work for me or I am not configuring the ini file to the correct location.

  4. Peter
    12:25 pm on August 18th, 2009

    Send me an email. I will see what we can do. Note that we used this on one site awhile ago and it worked instantly. Could be an .ini issue or permalink issue. You have to update the permalinks at the same time.

  5. Peter
    12:48 pm on August 18th, 2009

    FYI, this is the blog we did it on.

    http://www.searcylaw.com/blog/

    It’s on an IIS server, so I know it works.

  6. Peter
    12:49 pm on August 18th, 2009

    Finally, it could be that we are under a directory. Since your blog is the root, you may need to update accordingly the paths.

    #Rewrite wpcontent path (stylesheet, images, admin)
    RewriteRule /wp-(.*) / wp-$1 [I,L]

    #Removes index.php
    RewriteRule /(.*)$ / index.php/$1 [I,L]

    That might work.

  7. wp-popular.com » Blog Archive » Wordpress URL Rewrites for Windows IIS – How to Remove index.php Using HTTPD.ini file « Internet Marketing Blog with PaperStreet Web Design – Law…
    3:40 am on March 25th, 2010

    […] Read more: WordPress URL Rewrites for Windows IIS – How to Remove index.php Using HTTPD.ini file « Internet … […]

  8. antifree
    11:22 am on October 4th, 2010

    Permanent link set as directory path,if i use plugins of sitemap generator ,the sitemap file will can not be access,the rewrite must change as this—

    RewriteRule /blog/(.*)/$ /blog/index.php/$1 [I,L]

    if pseudo-Static set html as suffix,the code also add some word.

  9. Ravi
    3:47 am on November 1st, 2011

    Hi, Thanks for the tip.

    With WP 3.2, it automatically writes the rules to redirect.

    But, we have 1000s of pages already with numerous inlinks.

    If we change the URL to /year/month/day/postname, the redirect works without index.php.

    But if we change the URL to /postname then the previous URLs are showing page not found ( The site still works with new structure. The problem is with redirecting old URLs)

    Can any one let us know the redirect rules?

    We have only web.config access and no

    HTTPD.ini

    Thanks

  10. Colocation Docklands
    5:33 am on November 21st, 2011

    Thank you for your nice tips.These are helpful.

  11. Anonymous
    1:53 pm on December 20th, 2011

    Mike, just like .htaccess files, httpd.ini files affect the entire directory they are placed in. If you place the httpd.ini file in the root, then the entire web structure will be affected. If you place httpd.ini in the /blog/ subfolder, then only the /blog/ will be affected.

    That said, I recommend keeping the httpd.ini and .htaccess in the root folder for rewrites. As long as you add /blog/ to your rewrite rules in the root, then you should be good to go.

    If you experience otherwise, please let us know!

  12. Anonymous
    1:53 pm on December 20th, 2011

    Mike, just like .htaccess files, httpd.ini files affect the entire directory they are placed in. If you place the httpd.ini file in the root, then the entire web structure will be affected. If you place httpd.ini in the /blog/ subfolder, then only the /blog/ will be affected.

    That said, I recommend keeping the httpd.ini and .htaccess in the root folder for rewrites. As long as you add /blog/ to your rewrite rules in the root, then you should be good to go.

    If you experience otherwise, please let us know!

  13. Mukeshchauhan81
    7:35 am on January 3rd, 2012

    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.

    http://dotnetcodebytes.blogspot.com/2011/11/remove-indexphp-from-wordpress-on.html

  14. Matthew
    1:29 pm on April 2nd, 2013

    Out of the 15 or so examples I tried on the internet, this one works perfectly for me. Thank you so much for sharing.

Leave a Reply

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

*