Forum Discussion
frisco76_104868
Nimbostratus
Jul 10, 2009rewrite URI is not rewriting
hi all, I'm performing a URI rewrite. I want the rewrite to do the following:
anybody that has URI "/company/xyz", rewrite the URI to "/xyz". So http://www.mycompany.com/company/xyz/home.htm to http://www.mycompany.com/xyz/home.htm.
I expect to see my URL in the web browser to be http://www.mycompany.com/xyz/home.htm but I get http://www.mycompany.com/company/xyz/home.htm in the URL with the correct web page. If I remove the rule, and try to connect to http://www.mycompany.com/company/xyz/home.htm- I get 404 error so I know the page doesn't exist at the URL.
Any ideas why the URI isn't being rewritten in the browser? (Although I get the correct web page). In my debug, I see the new URI being written so I know its doing the job.
Here is my code:
when HTTP_REQUEST {
start debug
set testuri [HTTP::uri]
log local0.debug "> ****StartURI='$testuri'";
end debug
if { [HTTP::uri] contains "/company/xyz" } {
set variables
set origUri [HTTP::uri]
set origString "/company/xyz";
set newString "/xyz";
regsub -all $origString $origUri $newString newUri
start debug
set testuri [HTTP::uri]
log local0.debug "> ****StartURI='$testuri'";
log local0.debug "> ****EndNewURI='$newUri'";
end debug
write the new URI to HTTP session
HTTP::uri $newUri
string replace
}
}
- L4L7_53191
Nimbostratus
This is because you're redefining the URI (via HTTP::uri $newUri) before sending it on to the server. It happens 'behind the scenes' and is effectively obfuscating your URI to the client, sort of like a context-specific proxypass directive would work in Apache. The client is none the wiser. - frisco76_104868
Nimbostratus
Hi L4L7, thanks for the response. Hmm, I thought I had this working to rewrite the URI. - frisco76_104868
Nimbostratus
L4L7, Thanks for the example syntax, I appreciate it. I will try to implement this on Monday - frisco76_104868
Nimbostratus
The rule worked...thanks again for the response. - L4L7_53191
Nimbostratus
Great news, thanks for the update.
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