Forum Discussion

Ramprasath_K_19's avatar
Ramprasath_K_19
Icon for Nimbostratus rankNimbostratus
Jan 26, 2016

Redirction from https://abc.com to https://abc.com/xyz/

Hi kindly help me to fix the below requirement

 

I would like to redirect the site From https://abc.com to https://abc.com/xyz/ ( to a sub site)

 

I am using cookie persistence.

 

Thanks and Regards, Ram

 

1 Reply

  • Hi Ram,

     

    you may take a look to the two example below.

     

    Example1: Redirect just "/" (aka. Website ROOT) to /xyz/

     

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "abc.com" } then {
            if { [string tolower [HTTP::uri]] equals "/" } then {
                 Redirect just "/" (aka. Website ROOT) to /xyz/
                HTTP::redirect "https://abc.com/xyz/"
            } else {
                 You may want to implement additional code to handle request to other URIs.
            }
        } else {
             You may want to implement additional code to handle request to other HOST-names.
        }
    }

    Example2: Redirect everthing which is not /xyz to /xyz/

     

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "abc.com" } then {
            if { [string tolower [HTTP::uri]] starts_with "/xyz" } then {
                 You may want to implement additional code to handle /xyz requests.
            } else {
                 Redirect everthing which is not /xyz to /xyz/
                HTTP::redirect "https://abc.com/xyz/"
            }
        } else {
             You may want to implement additional code to handle request to other HOST-names.
        }
    }

    Cheers, Kai