PDA

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



Brian
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.


[ISAPI_Rewrite]

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

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




[ISAPI_Rewrite]

# 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 METHOD GET|HEAD
RewriteCond %HTTPS (on)|.*
RewriteRule (.*) http(?2s:)\://www.$1$3 [I,RP]


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


[ISAPI_Rewrite]

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

AlexY
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.


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

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


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

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


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

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

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

CalebC
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.

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