Rewritemap from simple URL?

Topics: User Forum
Mar 8, 2011 at 7:14 PM
Edited Mar 8, 2011 at 7:16 PM

Inhouse we have several simple redirect pages based on a simple URL.

For example, http://cirs2 redirects to http://server1/Reports/Pages/Folder.aspx and

http://ipmonitor2 redirects to https://server2.domain.com:443

I'd like to use IIRF to combine all of these into a single rule based site, but all the documentation is based on rewriting part of the URL for rewritemaps and not the entire URL.

How can I configure it for a rewritemap? I can make a basic rule for each site but it doesn't seem like best practices.

RewriteCond  %{HTTP_HOST}  ^cirs2$
RedirectRule ^/(.*)$       http://server1/Reports/Pages/Folder.aspx     [R=301]

RewriteCond  %{HTTP_HOST}  ^ipmonitor2$
RedirectRule ^/(.*)$       https://server2.domain.com:443    [R=301]

 

Thanks,

Coordinator
Mar 9, 2011 at 2:11 AM

I suggest something like this:

IIRF.ini:

# define the map
RewriteMap   redirects       txt:c:\maps\url_redirects.txt

# redirect requests for any hosts that are found in the map
RewriteCond  ${redirects:%{HTTP_HOST}|NotFound}  !NotFound
RedirectRule ^/(.*)$        ${redirects:%{HTTP_HOST}}  [R=301]

url_redirects.txt:

ipmonitor2    https://server2.domain.com:443    
cirs2         http://server1/Reports/Pages/Folder.aspx

 

Mar 11, 2011 at 1:50 PM

Thanks! It appears to be working in our testing.