Forum Discussion
Leslie_South_55
Nov 06, 2008Nimbostratus
HTTP::respond + append URI from HTTP::request
I am using the sample for HTTP::respond 301 from http://devcentral.f5.com/Wiki/default.aspx/iRules/findclass.html
I need to be able to grab anything after the host and append this to th...
Alok_3817
Nov 07, 2008Nimbostratus
Hi lsouth,
I am not sure why you want to use the HTTP::respond for achieving this, this can be acheved in a very simple format. Before I go ahead and type the iRule here, for the benefit of the newbies that might stumble across this post here are a few basics
Take a URL of a website, say iam trying to download chrome from Google, My adress bar will show
http://www.google.com/chrome
In this there are 3 parts
1. "http://" --> This is the protocol, other examples that you would see are https or ftp
2. "www.google.com" --> This is hostname of the ser ver you are trying to access (known as host)
3. "/chrome" --> This is URI or Uniform Resource Identifier, it refernces the location inside the server.
This is how we find our way in the websites
To reference all this in iRules, you can use the following tags [HTTP::host] and [HTTP::uri]
Please be informed that "/" is a part of URI, known as the root location. So when you try to access the host without an URI, your browser automatically appends the "/"
So for your case we can try and use the HTTP::redirect feature, as it does the 302 redirection as you want it
Use this iRule
when HTTP_REQUEST {
if {[HTTP::host] equals "host1.domain.com" } {
HTTP::redirect https://securehost.domain.com[HTTP::uri]
}
}
This will redirect your request and append your URI
so if anyone tries to access http://host1.domain.com/foo/foo/foo.bar he/she gets redirected to https://securehost.domain.com/foo/foo/foo.bar
Hope this helps
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