Forum Discussion
iRule Redirect When URI Immediately Contains "#"
Technically speaking, in the context that you're trying to use the hash character it isn't a TCL special character.
Let me also first say that using hashtags as URI components is a bad idea.
BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD
BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD
BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD
BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD
BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD
BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD
The hashtag is actually a special character in HTML and is called a fragment identifier. It is intended to point to resources that are not necessarily available on the server - in other words the hashtag is typically used in HTML to indicate resources that are subordinate components of an existing document (ie. anchor "jump to" tags in an HTML document). See the following for more information on fragment identifiers:
https://tools.ietf.org/html/rfc3986section-3.5
Modern browsers will not submit the hashtag portion of a URI to a server. In fact, if you're on an HTML page and click a link that points to a hashtag anchor on the same page, the browser will not submit a request at all. So try this example to see what I'm talking about:
when HTTP_REQUEST {
log local0. [HTTP::uri]
if { [HTTP::uri] equals "/" } {
HTTP::redirect "/site1//index.phptest"
}
}
You can try this with pretty much any browser and even command line cURL. Make you request to the root URI (/) and you'll get a 302 redirect to "/site1//index.phptest". The very next request will be:
/site1/
Why you ask? Because the browser sees everything after the first hashtag as a fragment identifier and excludes that from the resource request, so the first hashtag removes everything after it in the URI. So in your example, let's say you issue a redirect to:
https://bisystem//projects
Browser will see everything after the first hashtag as a fragment identifier and exclude this from the request, resulting in a request to "/", which is now causing your loop.
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