Forum Discussion
How do I do a 301 redirect to an exact URI only?
I have seen other example irules for redirection that have an undesired behavior.
What I want is for abc.com, abc.com/home, abc.com/careers.html, etc. to all be redirected to def.com/locations.
The examples that I have seen so far would cause abc.com/something/aboutus.html to redirect to def.com/locations/something/aboutus.html. Basically, anything in the requested URI would be appended to the redirected URI unless I had explicitly covered all possible cases in the first part of the irule.
I'm sure it's something simple that we're missing, but any tips on how to do this properly would be appreciated.
Thanks
4 Replies
- Vernon_97235Historic F5 Account
If I understand your requirements, you want all requests to abc.com to be redirected to a single alternative URL regardless of the request-uri fragment supplied for the original request. That is, http://abc.com/place/any/path/here?and=any&query=parameters would be redirected to the exact URL http://def.com/locations. If so:
when HTTP_REQUEST { HTTP::respond 301 Location "http://def.com/locations" }- MQKC_254171
Nimbostratus
Thanks. That worked perfectly. It looks like I just needed to remove the "[HTTP::uri]" from the end of the response command.
- VernonWells
Employee
If I understand your requirements, you want all requests to abc.com to be redirected to a single alternative URL regardless of the request-uri fragment supplied for the original request. That is, http://abc.com/place/any/path/here?and=any&query=parameters would be redirected to the exact URL http://def.com/locations. If so:
when HTTP_REQUEST { HTTP::respond 301 Location "http://def.com/locations" }- MQKC_254171
Nimbostratus
Thanks. That worked perfectly. It looks like I just needed to remove the "[HTTP::uri]" from the end of the response command.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com