Forum Discussion
dundovic_25174
Jan 23, 2012Nimbostratus
HTTP Class profile redirect
I understand this is iRule discussion forum and I can achieve this using iRule, but due to some specific customer requirements, they'd like to have it done using 'HTTP class' profile.
Following should explain the task.
Original URL:
http://Server1.domain1.com/Folder1/
Redirect to:
http://Server2.domain2.com/Folder2/
Basically, any request coming to 'server1' and 'Folder1' should be redirected to 'Server2'/'Folder2', but the rest of path should be retained. Could this be achieved using 'HTTP class' profile?
Thanks!
9 Replies
Sort By
- Seems like the rest of the path was removed...it should read:
- Here is the config I used (output from tmsh):
test-ltm-ve-03(Active)(/Common)(tmos) list ltm profile httpclass redirect_server1_to_server2
ltm profile httpclass redirect_server1_to_server2 {
app-service none
defaults-from httpclass
hosts { glob:Server1.domain1.com }
paths { glob:/Folder1 }
pool none
redirect http://Server2.domain2.com/Folder2/
}
Keep in mind that the matches are case sensitive, so if you are expecting different capitalization, you might want to use a regex (slower). Hope that helps,
-George
- Hi dundovic,
- Thanks for your suggestions, George. I'll try to find out if HTTP class can be somehow used in this scenario, otherwise, I'll have to proceed with an iRule, which was my original idea.
- As Michael showed, you can use iRule commands in the Redirect to Location field. So you can append the current URI using [HTTP::uri]. If you want to substitute a string (Folder1) for another (Folder2) within the URI, you could use:
- Thanks all! I appreciate your help. I didn't know iRule commands could be mixed with the field entries.
- Awesome! Thanks Michael and hoolio. I learned something today!
- How would you use the Headers -> Header List to redirect based on the value of a header? How do you specify the header and the expected value? Can you write: X-Roles="admin", for example, as a matching condition? I'm not sure I understand the intent of headers in the HTTP Class Profile dialog pictured above.
- Hi Curtis,
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects