Permalink for Wordpress – IIS 6 mod_rewrite FIXED – Free
If you install WordPress on IIS you will notice your friendly URLs do not work. This is because WordPress wants to use an apache add-on called “mod_rewrite.” The quick rundown of that this does is it will take your friendly browser URL and actually change them to index.php on the back end. One problem with this method is that IIS does not load apache mods. Here is an easy and free way around this:
- On your IIS Server download and install ISAPI_Rewrite Lite. This filter does the job of mod_rewrite for IIS. When downloading make sure to use the free Lite version. This Lite version does not limit the product very much and will be perfectly fine (and free) for our wordpress blog. Just install Rewrite Lite to the default locations for this tutorial.
- Next add the ISAPI filter to your IIS Site.
You will find this setting by right clicking yourIIS site -> properties -> ISAPI filters tab -> Add … Name the filter whatever you wish and your path to your executable should be:
C:\Program Files\Helicon\ISAPI_Rewrite3\ISAPI_Rewrite.dll
Click OK on both windows to save your settings. - Next navigate to C:\Program Files\Helicon\ISAPI_Rewrite3
Here we will edit httpd.conf (Note: This is the difference between the pay version and the Lite version. In the pay version you will need to edit the .htaccess file on your web folders root) - Open the httpd.conf file in wordpad and paste in these lines:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?p=$1 [NC,L] - Save and exit this file.
- To complete your IIS changes, Go to start, run and run the command: iisreset /restart
- Now lets change your WordPress settings. Navigate to http://yourblog/wp-admin
- Navigate to the left side menu bar -> settings -> Permalinks
- Now you get to choose how you want your posts to look. I choose a custom setting and just: /%postname% This is how you see this blog working today.
- Click “Save Changes” and you should see your new friendly URLs!
Drew says:
February 22nd, 2010 at 7:20 pm
Tried this step by step and no luck getting it to work. The current version ISAPI rewrite (v3) installs properly and does the majority of the updates above automatically with the exception of step 4. Manually edited the httpd.conf file and Wordpress STILL will not allow permalinks.
Any updates regarding this?
Lars CMS Meyer says:
March 9th, 2010 at 12:11 pm
Very nice wordpress trick – this works like a charm. No need to install og buy components to help rewriting, this is all you need. 5 minutes after finding this guide, my wordpress blog is now working with url rewritten permalinks, perfect
Excellent and easy follow guide, i’d recommend it to others.
Jared says:
March 12th, 2010 at 12:14 am
Hi Kyle- I really wanted this to work, but it doesn’t for me. At first, it just redirects to the generic Index.php that shows all of the info for the PHP version that’s currently installed. So then I renamed that generic index.php file to see if it would redirect to the correct one (the one associated with the blog posts). But it didn’t work…it just 404s on me.
I know you probably can’t answer individual comments, but if you have any insight, I’d love to hear it.
Thanks!
KyleCaulfield says:
March 12th, 2010 at 6:24 pm
It sounds like your httpd.conf is not correct… can you post it? Also, the httpd.conf needs to be in the folder: C:\Program Files\Helicon\ISAPI_Rewrite3 (or wherever you have it installed)
KyleCaulfield says:
March 12th, 2010 at 6:25 pm
Where is your HTTPD.CONF located? it needs to be in: C:\Program Files\Helicon\ISAPI_Rewrite3
Jared says:
March 12th, 2010 at 7:15 pm
Hi Kyle-
Thanks for writing back.
Yes, the httpd.conf is located in the C:\Program Files\Helicon\ISAPI_Rewrite3 folder.
The only thing listed in that file is the lines of code that you posted in the article:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?p=$1 [NC,L]
Before I pasted them, it was an empty file.
As I said, it worked in the sense that it redirected to the “index.php” file that is located in my website’s root folder (which is just the standard index.php file that you get when you’re testing to confirm that PHP is installed correctly). But once I renamed that file (for testing purposes), the redirect would simply go to a 404 page.
So it would appear that the redirect is working somewhat, but it seems to be pointing to the wrong file location. Does that sound about right to you?
In the past, I’ve had a lot of issues with giving the internet user account certain rights to other folders. Do you think that might be an issue here? I wouldn’t think so, since the “work” is being done on the server side, but stranger things have happened.
Thanks again for any insight you can give. I appreciate it.
Jared says:
March 14th, 2010 at 1:14 am
Okay, a bit of an update. Hopefully this can help us figure out what’s going on.
I changed the fourth line of code in the the httpd.conf file to include the path to the correct index.php file. So the new line looks like:
RewriteRule ^(.*)$ blog/index.php?p=$1 [NC,L]
Since my blog is not in the root directory, this tells the rewrite where to find the correct index.php. I can’t believe I didn’t think of that earlier. However, it still doesn’t function correctly.
Now, no matter which post I click on, it simply loads the “home” page of the blog. The browser address bar shows a nice permalink (www.mywebsite.com/blog/postname), but what appears on the screen is just the home page, not the actual post.
So we’ve taken two steps forward and one step back.
BTW, if I include the “index.php” as my permalink setting in WordPress, everything works great. (e.g. http://www.mywebsite.com/blog/index.php/postname)
But I’d prefer not to include that reference to index.php if I can help it.
Any thoughts?
KyleCaulfield says:
March 14th, 2010 at 3:01 pm
Jared — I have not tried to have my blog posted anywhere but the root site, but have you tried changing the line:
RewriteBase /
To:
RewriteBase /blog/
I think this might help. As for the security I had unrelated problems to that before but if security was not set correctly I think IIS would request a username and password from you. This issue is something with out ISAPI rewrite. Don’t give up! It is trying to work, we just need to massage the settings a little bit.
Kyle Caulfield
Jared says:
March 14th, 2010 at 4:24 pm
Just tried it.. no luck. It puts up a 404 error with that change if I try to go to the permalink without the index.php in there.
I know absolutely nothing about coding, so please take this with a grain of salt, but I wonder if it has something to do with the “?p=$1 [NC,L]” text in that last line.
It seems to me like the redirect is getting us to index.php, but isn’t pulling the correct post number from there, so it simply defaults back to index.php.
I think I’m stuck with “partly” pretty permalinks, at least for the time being. It’s not the end of the world, but it would be nice to avoid it if I can.
Thanks again for your response. I figured leaving the comments here would be best, just in case we discover a solution that can possibly help someone else with this issue in the future.
KyleCaulfield says:
March 14th, 2010 at 8:18 pm
No problem Jared — I want to get this working for you! Can you verify the settings in wordpress? Go to Settings in wp-admin and then go to permalinks and let me know how you have that set up. PS the p=? is how wordpress normally finds what post you are looking for, so I think you are on the right track.
Update:
Can you try this in your httpd.conf file:
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
Jared says:
March 15th, 2010 at 6:43 pm
Thank you for trying, but unfortunately, that didn’t work either. It still just redirects back to the blog’s home page.
In fact, everything redirects back to the blog home page (even 404 errors). Clicking on any link in the blog simply reloads the blog’s default page (even though the address in the browser’s address bar changes).
In my wordpress settings, I have to use /index.php/%postname%/ to make it work. Each time I test it, I remove “/index.php” so that it becomes simply: /%postname%/. But so far, we haven’t been able to make it work without keeping the “index.php” part in there.
KyleCaulfield says:
March 15th, 2010 at 7:21 pm
This is a shot in the dark, but you said you had /%postname%/ in your setttings… have you tried /%postname% ?
Jared says:
March 15th, 2010 at 8:51 pm
Yep, tried that one too. I’ve even tried it with a “.html” on the end.
It works just fine so long as index.php is in the path, but fails whenever it’s missing.
Jose says:
March 18th, 2010 at 7:28 pm
I’m having the same exact problem Jared is having. Any ideas?
Brent says:
March 19th, 2010 at 11:07 pm
Any solutions if you have it hosted elswhere on IIS6, and not having access to the IIS control panel? Thanks!
JC says:
March 25th, 2010 at 5:35 am
Thanks, after weeks of mind-numbing dealings with Apache on Windows I finally did what you said and it works for my Wordpress sites.
I believe that some of the problems posted here are because they are not using Wordpress since the matched pattern for what you write matches URL’s that contain index.php?p= .
If any other application is being used you will have to modify the httpd.conf accordingly.
If you want a particular pattern matched please email me at me@jcm7.com and I will try to help.
Almeros says:
March 26th, 2010 at 8:39 am
I had the same problem as Jared, and I found a fix for it (for Wordpress 2.9.2 with ISAPI_Rewrite3), so I hope it helps you too Jared!
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(index\.php)*(.*)$ index.php/$2 [NC,L]
I will explain some more about it on my own blog which should soon be online (at time of writing this) at code.almeros.com.
Jared says:
March 26th, 2010 at 8:21 pm
Almeros,
Thanks for posting. I *really* wanted it to work and was hoping it would. I went over the installation several times to make sure I was doing everything correctly and had typed it in right. I even cut-&-pasted your code to avoid errors, although I did have to add /blog to make sure it was referencing the correct index.php for my installation.
But alas, it did not work. It creates a 404 error when I take index.php out of the permalink path. But here’s the interesting bit…the 404 is a new one. It’s the one that is part of my blog theme, NOT the normal generic 404 from Windows. So it’s something new. And the title bar says “Nothing found for Blog Index Php Blog”, which I’ve never seen before.
I get the impression that we are really close to solving this, and that is has something to do with the syntax in that final line of code. But unfortunately, I’m just not smart enough to crack it.
Just in case it’s needed, here are all my “specs”:
-Windows 2003 service pack 2 64 bit (IIS running in 32 bit mode)
-MySQL 5.1
-PHP 5.2.13
-Wordpress 2.9.2
I think that’s it, but let me know if you need anything else.
Thanks guys for trying. I’m still keeping my fingers crossed.
KyleCaulfield says:
March 26th, 2010 at 10:02 pm
Jared — Stupid question, what version of WP are you running? Newest?
Jared says:
March 27th, 2010 at 8:40 am
See the last line of my previous comment: 2.9.2 Based on what I can see, I think that’s the newest non-beta release, but I could be wrong.
What are you running?
bobkknd says:
March 27th, 2010 at 8:39 pm
E, ,,
i like load~~~~
S00p3r J35u5 says:
March 29th, 2010 at 2:57 pm
I love u blog.
PlayTEX says:
March 30th, 2010 at 2:53 am
This has been bugging me too for sometime too.
Solution:-
Place this in your .htaccess file or .conf file depending on the version of Helicon ISAPI rewrite you have installed. (.htaccess file to be located in “blog” subdirectory)
Rule:-
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)$ blog/index.php/$1 [NC,L]
where “blog” is the subdirectory.
Turn permalinks on and use either
/%postname%/ for just a url or
/%postname%.html for articles to end in .html i.e.
Simple
Jared says:
March 30th, 2010 at 5:24 pm
PlayTEX…nope. Same issue as the last time I tried. It 404’s on me, using the blog theme’s 404 page instead of the generic Windows one.
(although with the spam in your comment, I probably should have guessed)
There must be some setting in/on my system that apparently is different from the others who have gotten this to work. Such is the life of a Windows server, eh?
21csm says:
April 8th, 2010 at 3:17 pm
I have the same problem as Jared. And none of solutions above helped me either.
WP settings are: /%year%/%monthnum%/%postname%/
httpd.conf:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
And as the result I have:
correct permalinks listed in browser’s address bar though every of them just leads to blog’s index page (with all posts listed).
Can anyone advise with the correct settings?
404’s on Wordpress Permalinks (IIS with ISAPI Rewrite) says:
April 9th, 2010 at 6:52 am
[...] [...]
Almeros says:
April 9th, 2010 at 7:08 am
Hi Jared and all others,
After I posted my last comment I was happily installing everything on my live server just to get yet another 404 problem :S. This time it was IIS. Today I solved it and I wrote a blog article about all my fixes for the Wordpress on IIS 404’s. Check it here: http://code.almeros.com/404-wordpress-permalinks-iis-with-isapi-rewrite
I really hope you can find your solution there now, because I know how annoying this is
.
21csm says:
April 11th, 2010 at 1:28 pm
Greetings to Jared and others.
I solved IIS / mod_rewrite problem for my site but without using Helicon ISAPI_Rewrite Lite. This particular module did not work before I put special PHP-hacks in wp-settings.php (like statement $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; in the very beginning of file) and even then I couldn’t fully adjust it.
I overcome Rewrite problem by using Ionics Isapi Rewrite Filter. It did not require anything to be patched in WP though I had to create rewrite rule for every special case.
You can see my configuration file shared.
Maybe it’s a kind of brute force method but it worked for me.
PlayTEX says:
April 13th, 2010 at 12:28 am
Hey,
If you are getting 404 errors have you actually checked that the rewrite is occurring?
I initially had this error and had to go through the Helicon log files to spot it… on doing so I reconfigured the site settings within plesk and it worked.
P.S last post only contained a link for reference to my blog that works… not spam
Rafael M says:
April 26th, 2010 at 6:59 am
What about those who do not have access to the IIS in their hosting?
I cannot even start by installing ISAPI_Rewrite Lite.
Any suggestions?
WordPress Removing index.php from URL | Vikram Pant says:
April 27th, 2010 at 4:20 am
[...] if you installed WordPress on Windows yourself, manually or via Web Platform Installer, then visit this link for steps to add URL rewrite abilities. Should take no more than 10 minutes from start to [...]
Max says:
April 27th, 2010 at 12:48 pm
Lars CMS Meyer said “…this is all you need. 5 minutes after finding this guide”
Yes i agree. I’d say it took me about 5 minutes to get Permalinks working in WordPress.. using ISAPI_Rewrite3 on IIS 6.0
Thanks for posting this – very useful !
Max says:
April 27th, 2010 at 1:03 pm
update… right after fixing the Permalinks in a Wordpress application, (as above) i spent the next 5 minutes undoing it all again as it trashed all of the other sites on the same server
Not sure what to do now? jump off the nearest high building?
Kyle Caulfield says:
April 30th, 2010 at 9:48 am
Max – Just enable the isapi filter for the sites you would like a friendly url, not all sites =)
Kyle
Taz says:
May 16th, 2010 at 9:51 am
First of all, thanks for the providing the step by step process. I followed the instruction and got the permalinks to work. However, it changed the contents of all the pages. Now even on every static page except home, it shows all the blog entries. So, other than home every page looks like the blog page. Is there anything I’m doing wrong? I’d appreciate any pointers you may have.
men of shuangxi says:
May 18th, 2010 at 11:45 am
I haven’t install wordpress on windows myself ,but i think if i do it also in the future, I can reference your method.
Chris says:
May 20th, 2010 at 10:33 am
For WordPress MU, I followed your instructions but added this to my httpd.conf:
RewriteEngine On
RewriteBase /
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . – [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Everything works great! Thanks for this write up!
Brian V. Hunt says:
May 29th, 2010 at 1:50 pm
Kyle et al,
I have the permalinks working with this code in the IsapiRewrite4.ini file:
RewriteCond %{REQUEST_FILENAME} ^wp-content.*
RewriteCond %{REQUEST_FILENAME} ^wp-admin.*
RewriteCond %{REQUEST_FILENAME} ^wp-include.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/(?!wp-)(.+)$ /index.php/$1 [I,L]
RewriteRule ^/sitemap\.xml$ – [L]
All of the links work fine with that code EXCEPT if I create drop-down menus with parent/child pages. Then when I click a child page on the menu, it displays a URL with the correct parent/child, but the page displayed is actually the parent page.
Anyone else see this?
Brian V. Hunt says:
May 29th, 2010 at 6:23 pm
Ok, all I have to say is that the best solution I’ve found for this is Andy Stratton’s plugin for WP. You just install it, activate it, and make sure that .htaccess is in your root.
It not only handles the rewrites for my top-level pages but FINALLY the child pages on my drop-down menu’s are working.
You can find the plugin here: http://theandystratton.com/2009/get-wordpress-permalinks-working-with-windows-iis-and-isapi-rewrite
Wordpress e seus permalinks | Tech3 says:
June 1st, 2010 at 11:35 am
[...] meu caso (IIS..) achei através de buscas esse site que fornece um arquivo para ser atualizado junto ao IIS e que fará a mudança [...]
Sally says:
June 6th, 2010 at 6:37 pm
Hi,
I have successfully installed ISAPI_Rewrite3_0073_Lite.msi
It seems to be working fine but I’m not sure how I can get it to remove all references of index.cfm from the url for all pages on the website?? Also I am using mura not wordpress
Neo says:
June 9th, 2010 at 8:23 am
Got it to work on Windows 2003 on IIS 6.0.
Here we go:
1. Install ISAPI Rewrite 3 Lite, just as it is described above.
2. Put this on the C:\Program Files\Helicon\ISAPI_Rewrite3\http.conf file:
# BEGIN WordPress
Options +Followsymlinks
RewriteEngine On
RewriteBase /yoursubdirectoryname/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
CheckSpelling On
# END WordPress
Restart IIS only if you’re just installed ISAPI Rewrite. You dont nedd to restart IIS each time you modified this file.
3. DO NOT install plugins or other stuff out there. You dont need it.
4. Enjoy
Phil says:
June 10th, 2010 at 11:36 am
Thanks Neo. That worked for me
OhYa says:
June 13th, 2010 at 4:16 pm
Well, I have tried all of the above to no avail.
I have IIS 6 (win2003)
using WordPress 2.9.2.
MySQL 5
When trying to visit a permalink page I get this,
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
lexx2gee says:
June 15th, 2010 at 7:50 am
Is there a way to allow certain extensions such as axd to be used with the filter running?
I set this up as per instructions and the permalinks worked fine but other aspects of my website (especially where using ajax) stopped working and started throwing errors etc.
Any ideas?
Everything Is Crap » Blog Archiv » mod_rewrite for IIS6 and IIS7 says:
June 15th, 2010 at 10:14 am
[...] Server 2003 work. KyleCaulfield.com has a page that explains everything that you have to do to get mod_rewrite working for Windows Server 2003/IIS6. Works for us! Tags: wordpress paul 0 Comments You are allowed to post a comment or to set [...]
Rich says:
June 20th, 2010 at 9:18 am
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(index\.php)*(.*)$ index.php/$2 [NC,L]
Works great!!!!
Windows 2003 IIS 6 with Joomla 1.5
Fully rewrites URL without /index.php/
Hiding says:
June 23rd, 2010 at 6:57 pm
I have the solution for you when you install ISAPI REWRITE on IIS 6. The Helicon isapi filter is defaultly installed for ALL of your sites. So I had it up and running for my wordpress site but all other sites were scr*** up. So just go to your IIS manage and click on ‘Web Sites’ folder and remove it from the ISAPI filters list. Worked wonderfully for me.
138zzz says:
July 1st, 2010 at 7:57 am
gogo
aswsw says:
July 1st, 2010 at 7:59 am
http://www.138zzz.com is a good learning website
wwerwr says:
July 2nd, 2010 at 7:24 pm
are you go to 138站长站
RED says:
July 5th, 2010 at 12:04 pm
Ok. I have installed but do not have an httpd.conf file but an httpd.ini file
I cannot edit the .ini file as it seems to be in use. placing ghe httpd.conf doesnt seem to do anything.
绯痕学园 says:
July 10th, 2010 at 12:52 pm
动漫ACG综合性论坛 绯痕学园:http://www.yonkon.com/bbs
BIA says:
July 20th, 2010 at 1:05 pm
Thanks, worked great!
romenov says:
July 30th, 2010 at 3:09 pm
I helped this guy on an IIS with his prophoto theme, but he is running IIS and is using HTTPD.ini for his permalinks, he doesn’t have any install access, but ISAPI should be running.
The content is:
[ISAPI_Rewrite]
# For file-based wordpress content (i.e. theme, admin, etc.)
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php\?$1 [L]
# /index.php/ is not really necessary
# RewriteRule ^/$ / [L]
# RewriteRule /(.*) /\?$1 [L
now that works fine, say site/test , site/blog/postname , but when you try site/blog/page/2 it fails .. also when running qtranslate, when you go site/en/ it also fails, any suggestions?
I can’t find help on this
mpthemes says:
August 8th, 2010 at 8:52 am
Thanks! This help me a lot!
DDF Zone Diaries – Wordpress Pretty Permalinks – Windows IIS 5.1 « DDFZONE says:
August 25th, 2010 at 12:23 am
[...] [...]
Lars says:
September 1st, 2010 at 3:49 am
This worked fine for me. My only problem was the with the installation of the rewrite plugin it automatically installed over all websites. So after i skipped step 2 everything was working fine.
Windows server 2003(Vserver)
IIS 6
Wordpress > 3.0
Billy Clarke says:
September 3rd, 2010 at 5:01 am
Please help!
I’m working on a MAC, WP is installed on client server (Windows) and I’ve downloaded the plugin, uploaded files and installed, but it still doesn’t work.
You mention things like “You will find this setting by right clicking yourIIS site -> properties -> ISAPI filters tab -> Add … Name the filter whatever you wish and your path to your executable should be:
C:\Program Files\Helicon\ISAPI_Rewrite3\ISAPI_Rewrite.dll
Click OK on both windows to save your settings.”
As I’m on a MAC, I cannot see this OR, am I being blind?
Please help
Kyle Caulfield says:
September 3rd, 2010 at 7:29 am
Hi Billy
What is your web server? IIS or Apache?
Thanks
Kyle