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

url rewrite request

Babar_Ansari
Nimbostratus
Nimbostratus

I need to perform url rewrite wherein my original url will be https://abc.com and its subdirectories as well like https://abc.com/abc or https://abc.com/abc/xyz

My requirement is to add www before the url host portion. for eg: https://abc.com to https://www.abc.com , https://abc.com/abc to https://www.abc.com/abc, https://abc.com/abc/xyz to https://www.abc.com/abc/xyz

 

Kindly help with an iRule to achieve the same as i've tried multiple iRules but they don't work.

 

Regards,

Babar Ansari

2 REPLIES 2

Did you tried to use rewrite profile for this requirement?

SanjayP
MVP
MVP

Rewrite is on the serverside of the session, which is from the F5 to the backend server and it won't be visible to the clients on browsers. If you need a rewrite of the HOST header on the serverside of the session you can use below iRule

when HTTP_REQUEST {
     set host [string tolower [HTTP::host]]
     if {$host eq "abc.com"}{
	 HTTP::header replace "Host" "www.abc.com" 
     return
   }
 }

Redirect is a is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. If you are looking for a redirect, below is the iRule

when HTTP_REQUEST {
     set host [string tolower [HTTP::host]]
     if {$host eq "abc.com"}{
	 HTTP::respond 301 Location "https://www.abc.com[HTTP::uri]"   
     return
   }
  }