Forum Discussion

Marty_59927's avatar
Marty_59927
Icon for Nimbostratus rankNimbostratus
Jan 28, 2009

iRule - Redirect

I'm trying to redirect from domain1/uri to domain2/uri only if there is no .ext in the uri.

 

 

ie:

 

http://www.domain-1.com/any_subdir will redirect

 

http://www.domain-1.com/any_subdir/file.ext will 'not' redirect

 

to

 

http://www.domain-2.com/subdir

 

 

I've tried numerous ways, to no avail.

 

Any help would be greatly appreciated.

 

 

Thanks in advance.

 

 

-----

 

when HTTP_REQUEST {

 

set uri [HTTP::uri]

 

set host [HTTP:host]

 

 

if { [HTTP:host] contains "www.domain.com }

 

if { [HTTP:uri] not ends_with (matches_regex {\.\w+}) }

 

{

 

 

HTTP::redirect "HTTP://www.domain-2.com/$uri}}

 

-----
No RepliesBe the first to reply