There have been many requests lately to update WordPress and Joomla installations to use URL rewriting techniques to create SEF links. We use the robust and flexible IIS Web Server from Microsoft as our primary platform for over 10 years. IIS 6 does not support MOD_Rewrite which many Linux converts are used to seeing. Instead we use a tool called ISAPI_Rewrite for our shared hosting customers (also available for dedicated/virtual server customers). Currently we are running ISAPI_rewrite 2 on the shared server and will soon upgrade to version 3.
ISAPI_rewrite 2
I have compiled some version 2rules (below) you can use in your httpd.ini files. This is the files that is used to create the rewrite rules and should be placed in the root directory of your website (wwwroot folder). See: http://www.ephost.com/support/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=89 for more information.
ISAPI_rewrite 3
We do not currently support ISAPI_rewrite version 3. The rules below are for version 2 only! When we do start to enable version 3 you can use mod_rewrite rules pretty much verbatim as the tools are very similar. When we do upgrade you may need to upgrade your httpd.ini file or make some small changes.
WordPress Rules:
If you are using WordPress and would like to hide the index.php file name form your URLS you can use the rules below. Make sure to edit your WordPress installation’s permalink function to remove index.php from the URL. This is usually done in the “custom” field option. It would look something like:
[ISAPI_Rewrite]
RewriteCond Host: your_domain\.com
RewriteRule (.*) http\://www.your_domain.com$1 [I,RP]
RewriteRule /(?!index\.php)([^/.]+)/ /index.php/$1 [I]
RewriteRule /(?!index\.php)([^/.]+) /index.php/$1 [I,L]
Joomla Rules:
If you are using a new version of Joomla you can enable SEO rules from the General Configuration options in the site administrator menu. Enable all three check boxes as shown in the image below. Then implement the rules below in your httpd.ini file for ISAPI_rewrite v2.
[ISAPI_Rewrite]
# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule /httpd(?:\.ini|\.parse\.errors) / [F,I,O]
# Block external access to the Helper ISAPI Extension
RewriteRule .*\.isrwhlp / [F,I,O]
#Fix MyBlog’s SEF URLs
RewriteRule ^/(.*)\.html /$1
#Keep Isapi_Rewrite from rewriting URLs that look like regular files
RewriteRule ^/(.*\.[a-zA-Z1-9]{2,4}) /$1 [L]
# Excluding the administrator section
RewriteRule ^/(administrator\/.*) /$1 [L]
#Get rid of the index.php
RewriteRule ^/(.*) /index.php\?/$1 [I,L]
More than one way…
There are many ways these rules can be written and for many different reasons. If you find a flaw in the logic above please feel free to report it or make some alternate suggestions.