Forum Discussion

Dave_Pisarek's avatar
Nov 14, 2021

Root domain redirect that ignores uris

I have an interesting ask and I am guessing this has been asked before but not finding an answer. A customer wants to protect a root domain page by not allowing clients to connect to it but does not want to effect traffic to the uris.

 

Example:

 

Redirect traffic to jobs.com to hired.com.

Allow traffic to jobs.com/search or jobs.com/rehired, they have thousands of uris so can't just specify the uris in the rule.

 

Doing a simple equals redirects all uris to the hired.com.

 

when HTTP_REQUEST {

  if {[HTTP::host] eq "jobs.com"} {

    HTTP::redirect "https://hired.com"

}

}

 

How can we specify to allow anything after the jobs.com/* to be allowed but redirect the root?

 

  • Yes, this has been answered many times. You can use something like below.

    when HTTP_REQUEST {
       if {[HTTP::uri] equals "/"} {
            HTTP::respond 301 Location "https://hired.com"
            return
       } 
    }

    Please note, this would need modification if you have any further custom requirement.