Forum Discussion
Alexis_Verb__23
Jul 01, 2011Nimbostratus
Irule redirect --> problem with character "#"
Hello,
I'm facing trouble with creating a simple redirect irule. I want to redirect everthing from http://mywebsite.com/{sth} to http://www.mywebsite.com/{sth}.
Here is the irule I've written :
when HTTP_REQUEST {
if { [HTTP::path] equals "/" and
([HTTP::header "User-Agent"] contains "iPhone"
or [HTTP::header "User-Agent"] contains "iPod"
or [HTTP::header "User-Agent"] contains "Android"
or [HTTP::header "User-Agent"] contains "Apple Mobile Safari")} {
HTTP::respond 301 "Location" "http://mobile.mywebsite.fr/news/"
}
elseif { [HTTP::host] equals "mywebsite.fr" }{
HTTP::respond 301 "Location" "http://www.mywebsite.fr[HTTP::uri]"
}
else {
pool mywebsite-pool
}
}
Anayway, in the [HTTP::uri], I often have the "" character, and it does not work.
Example :
If I try with http://mywebsite.fr//test I am redirected to http://www.mywebsite.fr/.
Does anyone know how to deal with that?
Thanks a lot,
Alexis.
- Colin_Walker_12Historic F5 AccountIt looks like you're making this a lot more complicated than it needs to be, unless I'm missing something. If all you want to do is ensure there is always a www on the host, all you'd need is:
when HTTP_REQUEST { if{[HTTP::host] eq "mywebsite.com"] { HTTP::redirect "http://www.mywebsite.com[HTTP::uri]" } }
- hooleylistCirrostratusClients shouldn't include an anchor tag in the request they send to the server. It's something that is used clientside on the browser to load specific content on the page. If you log the HTTP::uri value, you should see that the tag isn't present in requests.
- Alexis_Verb__23Nimbostratus@Colin,
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