View Full Version : Isapi_Rewrite version 2 - redirect /voip to /phone.html

June 11th, 2009, 09:53 PM
On our Windows servers, some have Isapi_Rewrite version 2 and some have Isapi_Rewrite version 3.

This sample is for Isapi_Rewrite version 2.

Your Isapi_Rewrite configuration file must be named httpd.ini

In this example, let's say you want to have http://your_domain.com/voip redirected to http://your_domain.com/phone.html

To acomplish this with Isapi_Rewrite, create a httpd.ini file and place this code in it, and place the file in the root of your web files.


RewriteRule /voip([^/]*) /phone.html [I,L]

November 18th, 2009, 05:44 PM
Here are some additional Isapi_Rewrite version 2 examples:


# Move anything from non- www.example.com -> www.example.com
# e.g. example.com -> www.example.com
RewriteCond %HTTPS off
RewriteCond Host: (?!^www.example.com)(.+)
RewriteRule /(.*) http\://www.example.com/$2 [I,RP]

# Same as above but for SSL.
RewriteCond %HTTPS on
RewriteCond Host: (?!^www.example.com)(.+)
RewriteRule /(.*) https\://www.example.com/$2 [I,RP]

#Generic rule to redirect www. to non www., will work for any domain.
RewriteCond Host: ([^.]+\.[^.]+)
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?2s:)\://www.$1$3 [I,RP]

Here is another working example of redirecting from non www to with www.


RewriteCond Host: ^some_domain.com
RewriteRule (.*) http\://www.some_domain.com$1 [I,RP]

December 30th, 2009, 12:57 AM
Here is an additional Isapi_Rewrite version 2 example:

This will help prevent hot-linking of your image files. Hot-linking appears when another site uses your artwork and your images by linking directly to their location on your server.

RewriteCond Host: (.+)
RewriteCond Referer: (?!http://\1.*).*
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]

January 27th, 2012, 05:27 PM
If you are using joomla you will need this in your httpd.ini file.


# 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]

If you are using wordpress you will need this in your httpd.ini file.


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]

January 30th, 2012, 11:59 AM
You can use this to fix the missing trailing slash character on folders.

#Fix missing trailing slash char on folders
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

January 30th, 2012, 01:23 PM
If you need to exclude .cfm queries while having other rewrites take effect for the site for php or asp you can use the following code run before the rest.

#Exclude cfm queries
RewriteRule ^(.*\.cfm.*)$ $1 [I,L]