Forum Discussion

Hol_Admins's avatar
Hol_Admins
Icon for Nimbostratus rankNimbostratus
Jan 14, 2021

URL redirection based on port and path

I need help to redirect the URLs

https://web.example.com

https://web.example.com/Site/

https://web.example.com/site/

https://web.example.com:9443/

https://web.example.com:9443/Site/

https://web.example.com:9443/site/

 

to 

https://web.example.com:9443/Site/

1 Reply

  •  ,

    Now as you want redirection on port 443 as well as 9443, so you would need two separate virtual servers using same IP (which is associated with web.example.com) which will be listening on both these ports. You can also have single virtual server which will listen on both ports using port list option.

    First 3 redirection will be carry out by virtual server which is listening on port 443 and remaining redirections will be done by virtual server which is listening on port 9443.

    You can bind below iRule to each of the virtual server for the redirection.

    when HTTP_REQUEST {
    if { [HTTP::host] contains "web.example.com"}{
    if { ([HTTP::uri] equals "/") || ([HTTP::uri] equals "/Site") || ([HTTP::uri] equals "/site")}{ 
    HTTP::redirect https://web.example.com:9443/Site/
    }
    } 
    }

    Hope it helps!

    Mayur