Is it possible to disable https redirect when a specific user-agent is found?

I am currently working on a website and because I have a Nintendo DSi which has internet access but does not support https, I was wondering it is possible to not auto rewrite if it finds "Nintendo DSi" in the user-agent?
1 Reply
MattIPv4
MattIPv43d ago
Yup, very doable! Setup a redirect rule for http -> https and add a condition to exclude the user agent in question. With the UA you don't want to upgrade:
~ ❯ curl -is http://other.v4.fyi -H "User-Agent: Nintendo DSi" | grep -e HTTP -e Location
HTTP/1.1 522
~ ❯ curl -is http://other.v4.fyi -H "User-Agent: Nintendo DSi" | grep -e HTTP -e Location
HTTP/1.1 522
This returned a 522 'cause I didn't setup an origin for the demo With any other UA it gets upgraded:
~ ❯ curl -is http://other.v4.fyi -H "User-Agent: Something Else" | grep -e HTTP -e Location
HTTP/1.1 301 Moved Permanently
Location: https://other.v4.fyi/
~ ❯ curl -is http://other.v4.fyi -H "User-Agent: Something Else" | grep -e HTTP -e Location
HTTP/1.1 301 Moved Permanently
Location: https://other.v4.fyi/
No description

Did you find this page helpful?