Forum Discussion

steven_normole's avatar
Jun 08, 2025
Solved

URI Redirect

I thought it would be simple, but i guess i am just too thick.

I need to have a redirect done, only if the URI does not contain a certain URI.

If the URI contains /vss-df,  or /vvs-df/appoitnment, etc then there is no redirect.  all other URI would redirect to the URL in the irule.

Do not redirect if the URI contains vvs-df

https://website/vvs-df,  https://website/vvs-df/appointments, etc

Direct:

https://website/,   https://website/

 

 

 if { ([HTTP::host] contains "<hostname>") }
        if { [HTTP::uri]] ne "/vvs-**") } {
        HTTP::redirect "<redirect URL>"
    }
}

 

  • Hello, you were close but equals and ne cannot be used with wildcard 

    try this

    when HTTP_REQUEST

    {
        if { [HTTP::host] contains "<hostname>" }

        {
            if { !([HTTP::uri] contains "/vvs-df") }

           {
                HTTP::redirect "https://<redirect-URL>"
            }
        }
    }

2 Replies

  • Hello, you were close but equals and ne cannot be used with wildcard 

    try this

    when HTTP_REQUEST

    {
        if { [HTTP::host] contains "<hostname>" }

        {
            if { !([HTTP::uri] contains "/vvs-df") }

           {
                HTTP::redirect "https://<redirect-URL>"
            }
        }
    }

    • steven_normole's avatar
      steven_normole
      Icon for Cirrus rankCirrus

      thank you, i was trying this and it would just redirect regardless

      I was trying this if {![HTTP::uri]] starts_with "/vvs-df/") } {