cancel
Showing results for 
Search instead for 
Did you mean: 

Rewrite URL iRule

darrenclegg
Nimbostratus
Nimbostratus

I have used redirect before and they have worked but can't get this rule to work.

 

When a user browses to abc.co.uk i want to change the URL in the browser bar to www.abc.co.uk. i have tried the following without success:

 

when HTTP_REQUEST {

 if { [HTTP::host] equals "skipton.co.uk/" } {

 HTTP::header replace "Host" "https://www.skipton.co.uk/"

}

}

*with the / on the end

 

when HTTP_REQUEST {

if { [HTTP::host] equals "skipton.co.uk"}

{ HTTP::header replace Host "www.skipton.co.uk"

}

}

*without the / on the end

 

when HTTP_REQUEST { 

if { [HTTP::host] equals "skipton.co.uk" } { 

HTTP::redirect "https://www.skipton.co.uk[HTTP::uri]" 

}

}

 

Can anyone see why it does not work and how to fix it? Much appreciated.

1 REPLY 1

 ,

 

Below iRule looks good, it should work.

 

 

when HTTP_REQUEST { 

 

if { [HTTP::host] equals "skipon.co.uk" } { 

 

HTTP::redirect "https://www.skip.co.uk[HTTP::uri]" 

}

}

 

Check under iRule statistics if you are seeing hits to it.

 

Mayur