Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

https non www redirect

cymru81
Altocumulus
Altocumulus

Hi, im trying to use an irule to direct traffic from https://example.com to https://www.example.com, im using the following but it just wont work! Any suggestions appreciated!

 

when HTTP_REQUEST {

if {[string tolower [HTTP::host]] equals "example.com"} {

HTTP::respond 301 Location "https://www.[HTTP::host][HTTP::uri]" 

}}

3 REPLIES 3

Hi cymru81,

This iRule should work. Is there any other irule attached in virtual server?

After adding the log lines, can you investigate the ltm logs?

when HTTP_REQUEST {
	log local0. "wwwredirect1 | Host: [HTTP::host]"
	if { [HTTP::host] equals "example.com" } {
		log local0. "wwwredirect2 | Host: [HTTP::host]"
		HTTP::respond 301 Location "https://www.[HTTP::host][HTTP::uri]"
		return
	}
}

cymru81
Altocumulus
Altocumulus

Hi, thanks for the reply - no other irules are applied.

if i enable the logging, where can i pickup the logs from to review please?

cymru81
Altocumulus
Altocumulus

just checking the ltm log and this (obv replaced) is logged for the VS, if that could be relevant (2.2.2.2 being the VIP)?

 

SSL Handshake failed for TCP 1.1.1.1:35262 -> 2.2.2.2:443