tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michel <compu...@videotron.ca>
Subject Re: URL Rewrite
Date Sun, 05 Sep 2010 22:38:49 GMT

----- Original Message ----- 
From: "André Warnier" <aw@ice-sa.com>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Sunday, September 05, 2010 11:38 AM
Subject: Re: URL Rewrite


> michel wrote:
> ...
>
>>
>> André, I am not sure that I understand but I think that I do. In this 
>> case, I believe that HTML  does interpret links in a natural way. 
>> Normally, the HTML picks up the base href from the toolbar. In the case 
>> of a forward with a  clean URL in the toolbar, we already have an 
>> unnatural HTML process going on. But I am only using the base href on 
>> that single page anyway.
>>
> I will take your last phrase above first.
> If that is true, and if it remains that way, then it is not a big problem.
>
> But if you find yourself in a situation where you start having to use the 
> "base href" mechanism in more pages, then stop and rethink the whole thing 
> before you do that.
> Because it is the kind of thing where you start by putting your little 
> finger, and before you know it, your whole arm will be sucked into it 
> also.
>
> Now about the rest.
> The browser does not really look at the toolbar or the URL input box.
> The browser gets a page from a server, and it interprets that page.
> When it does that, the browser knows one thing : from which absolute URL 
> it received the current page.  That is its starting point to interpret the 
> links that are contained in the page.
> In other words, *the URL from which it received the current page* is its 
> "natural base href".
> But when inside that page, you use the <base href=...> directive, then you 
> force the browser to ignore where-from it has received the current page, 
> and to use this new "base href" instead.
>
> That is a very blunt instrument, because it influences the way in which 
> the browser is now going to interpret all the relative links inside the 
> page.
> So it is like a big hammer to hit a small nail, and you should be very 
> careful with it.
>
> For example, if you give a copy of all your website pages to a website 
> graphic designer, to improve the look, then it means that this graphic 
> designer will not be able to easily "simulate" your website on his own 
> computer, just because all the links will be interpreted wrongly (they 
> will keep linking to your original website, instead of his copy).
>
> For example also, it means that if one day you decide that your clients 
> have to go through a proxy server to access some of your pages, you may 
> have problems because browsers will try, for some links, to keep accessing 
> the original server directly.
>
> You get the idea.
>
> What I mean in general, is that fixing your problem using a "base href" 
> may be a quick solution in this particular case, but it is probably not 
> the "right" solution in general, and may cause you more problems later on. 
> The right solution would be to make sure that all the relative links in 
> your pages, when they are interpreted by the browser and requested from 
> the server, are also being caught by the rewriting mechanism on the 
> server, and properly redirected to where they should.
> And preferably, that this would happen internally on the server, without 
> sending a redirect response to the browser and forcing the browser to make 
> a second request for everything.

André, I think that you are correct, but I have limited skills in URL 
rewrite, and I found that getting this part to work was a major pain. I 
should, in time, return to this. But there is also the case (in this case at 
least) where the base url is in a JSP and is dynamically generated by a 
bean, so I am not so sure that generating it from a URL rewrite is any 
better.

Michel



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message