Pretty Permalinks and Mod Rewrites in IIS 6 are a pain…
A bit of a different article than usual on RGT, but I realize some of you may be having a few issues with this particular problem.
There’s an option on WordPress (along with other CMS applications) to make ‘pretty’ permalinks. This will get rid of the index.php out of a link. In short url.com/index.php/posthere becomes url.com/posthere (or whatever other setup you choose to have.
This can be done fairly easily if you’ve got a apache as a file server (rather than IIS 6) – although you’ll need to create a .htaccess file. If in doubt – create one in notepad, upload it via FTP and then rename it to .htaccess. In the .htaccess file you’ll need to add in a little code – simply copy and paste this in.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
After that’s and select the correct link structure that you want under WP-admin -> settings, permalinks. Simples.
Things get a little tricker with earlier versions of windows however. If you’re using IIS 6 to do things, it doesn’t easily support such rewrites. The easiest trick I’ve found is to use third party applications. There are a couple which do the same thing – personally I’ve used http://www.helicontech.com/download-isapi_rewrite3.htm (I’ve no affilation with this BTW) – you can use the LITE version just fine for our purposes. Please ensure that you’re using the correct version (in other words, 32 or 64-bit) for your OS.
Download it and install it – the default install path is just fine. For me, the default install is C:\Program Files\Helicon\ISAPI_Rewrite3.
Once it’s downloaded, open up IIS 6 manager. (start -> admin tools – IIS manager). Navigate to the website that’s the issue and right click on it and select properties. Open up the tab labeled as “ISAPI Filters”. Click on Add… and navigate to the location you’ve installed the application to. You can name the filter anything – I personally went with rewrite. Click ok.
Open windows explorer and open the file httd.conf in notepad. Paste in the following text:
# BEGIN WordPress
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(index\.php)*(.*)$ index.php/$2 [NC,L]
# END WordPress
The RewriteBase / is important!!! This is the folder your WP (or other CMS) is installed in. BE SURE to set it correctly. / is the root (home directory).
You’ll need to restart the IIS services now too. To do this, click start -> run and type in cmd -> press enter. Type the following in (without quotes) “iisreset /restart”.
Then open up your website and navigate to the control panel, to the settings, and to the permalinks and change to what you need it to be. NOTE – I had a small issue with my setup where I had to reapply the ISAPI filter as it didn’t take the first time. I believe it could’ve been a glitch with Remote Desktop – but thought I’d throw it out there anyway.