I have requested to create iRule which will add appending to url, as the customer will write (http://mycompany.com ) and the application won’t work unless you write the following (http://mycompany.com/test/app.aspx )
1) I created the following irule but the pictures on the page doesn’t appear
when HTTP_REQUEST {
if { not ([HTTP::uri] starts_with “/test”) } {
HTTP::uri /test/app.aspx [HTTP::uri]
}
}
2) I used redirection irule like this and it works but I don’t know if this will affect the application
when HTTP_REQUEST {
if {
[HTTP::uri] equals “” or [HTTP::uri] equals “/” } {
For the first iRule, let’s say your incoming URI is “/foobar”. You are resetting the URI to the “/test/app.aspx /foobar”. I’m assuming that isn’t what you want to do. If you just want to change the URI to /test/app.aspx" then leave out your trailing [HTTP::uri] from the assignment.
If you just want to rewrite requests to the root document (path equals /), you could use this:
when HTTP_REQUEST {
Check if path is /
if {[HTTP::path] eq "/"}{
Rewrite path to /test/app.aspx
HTTP::path "/test/app.aspx"
}
}
If you want to prepend a string to all URIs if it’s not there already, you can use a rule like this:
when HTTP_REQUEST {
Check if path doesn't already start with /test/
if { not ([HTTP::path] starts_with "/test/")}{
Rewrite path by prepending "/test/"
HTTP::path "/test/[HTTP::path]"
}
}
Note that if you don’t care about inspecting the query string it should be more efficient to modify just the path using HTTP::path.
Right now I am doing a straight redirect based on two different paths, but now my users want to add arguments to the paths how can I do this? Below is the current rule and an example of the url the users are trying to use.
so basically the redirection takes you to the apache server running on 4444 instead of 443, but the question is if a user hit https://www.server1.com/test/USERNAME -or- https://www.server1.com/dev/PROJECT the redirect takes them to the mainpage (since that is what the rule tells it to do), but how can I grab the PROJECT code or the USERNAME and pass that to the redirect or append it to the redirect?