I have a use case where I would like all requests to start with a prefix like:
https://WHATEVER/pfx
For example https://WHATEVER/pfx/a and https://WHATEVER/pfx/b/c/d
But I wish to prevent https://WHATEVER/somewhere_else and similar requests that do not include the prefix (pfx). In preventing this, I'd like to simply redirect all such requests to https://WHATEVER/pfx (home page)
Is this possible with AWS ALB?
Thanks in advance!
Yes. You would create a rule that forwards traffic that matches the pattern "https://whatever/pfx/*" and probably also "https://whatever/pfx" to your target group. The second pattern can be included in the same rule and is intended to match the target without the trailing slash.
Then you would create another rule below that rule with the pattern "http://whatever/*" with an action of redirect and a target of "https://whatever/pfx"
Finally you need to figure out what to do with the default. It sounds like redirecting to "https://whatever/pfx" may be the behavior you want. So you may be able to omit the second rule and just configure the default behavior.
You may also want to consider a rule that redirects http://whatever/* to https://whatever/ if users may hit your site without "s" in https.