Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

HTTPS to HTTP when having another Irule for HTTP to HTTPS

Hello , im trying to redirect make a redirect on a specific page www.domain.com/page1/ to work without the https. i've tried many of suggestions here/google and did not had luck yet . i do have another rule for that domain from http to https what im trying to do is to make another rule which will redirect the only specific page to http. can it be done? on which way?

Thank you.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hello Chenco,

Add this irule to your HTTP VS

when HTTP_REQUEST {

    if { [string tolower [HTTP::path]] starts_with "/page1/" } {
       # do nothing only log to verify that it works properly 
       log local0. "[HTTP::path]"
    } else {
      HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
    }

}

And add this irule to your HTTPs VS

when HTTP_REQUEST {

    if { [string tolower [HTTP::path]] starts_with "/page1/" } {
         HTTP::redirect http://[getfield [HTTP::host] ":" 1][HTTP::uri]
    } else {
       # do nothing only log to verify that it works properly 
       log local0. "[HTTP::path]"
    }

}
0
Comments on this Answer
Comment made 01-Jun-2017 by Piotr Lewandowski 1160

Small one but in above there is missing dot in

log local0 "[HTTP::path]"

should be

log local0. "[HTTP::path]"

Piotr

1
Comment made 01-Jun-2017 by Jad Tabbara (JTI) 2360

Thanks Piotr, I missed it

0
Comment made 01-Mar-2018 by Chenco 62

Sorry for bumping this old thread , How I make this irule to work on specific domain only? on the same VS i have many more domains. Thank you.

0
Comment made 01-Mar-2018 by Darren Walker 226

Chenco,

I think this is how you do it:

when HTTP_REQUEST {

if { ([string tolower [HTTP::host]] equals "www.example.com") && ([string tolower [HTTP::path]] starts_with "/page1")} {
     HTTP::redirect http://[getfield [HTTP::host] ":" 1][HTTP::uri]
} else {
   # do nothing only log to verify that it works properly 
   log local0. "[HTTP::path]"
}

}

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hello Chenco,

You should modify your condition to

if { ([string tolower [HTTP::path]] starts_with "/page1/") && ([string tolower [HTTP::host]] equals "www.example.com") }

Regards

0