Results 1 to 6 of 6

Thread: Isapi_Rewrite version 2 - redirect /voip to /phone.html

  1. #1
    Join Date
    May 2009
    Location
    Tulsa, OK
    Posts
    220

    Default Isapi_Rewrite version 2 - redirect /voip to /phone.html

    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.

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

  2. #2
    Join Date
    May 2009
    Location
    Tulsa, OK
    Posts
    220

    Default

    Here are some additional Isapi_Rewrite version 2 examples:


    Code:
    [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.
    Code:
    [ISAPI_Rewrite]
    
    RewriteCond Host: ^some_domain.com
    RewriteRule (.*) http\://www.some_domain.com$1 [I,RP]

  3. #3
    Join Date
    Jul 2009
    Posts
    182

    Post Blocking inline-images (stop hot linking)

    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.

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

  4. #4
    Join Date
    May 2010
    Posts
    20

    Default

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

    Code:
    [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.

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

  5. #5
    Join Date
    May 2010
    Posts
    20

    Default

    You can use this to fix the missing trailing slash character on folders.
    Code:
    [ISAPI_Rewrite]
    #Fix missing trailing slash char on folders
     RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

  6. #6
    Join Date
    May 2010
    Posts
    20

    Default

    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.
    Code:
    [ISAPI_Rewrite]
    #Exclude cfm queries
    RewriteRule ^(.*\.cfm.*)$ $1 [I,L]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •