URL 重写如何工作?
我读过很多关于重写的文章和博客,我知道内部服务器重写和重定向之间存在区别。我有兴趣了解内部重写是如何工作的,以及在 Java 中是如何完成的。我正在为我的 Java Web 应用程序使用 PrettyFaces,如果能够知道如何(当然是非常简单的术语)在提供请求之前查看请求,那就太好了。它是一种首先调用的过滤器吗?
最后,服务器上的 url 重写是“程序”,它将重写规则中的 URL 转换为服务器上的真实资源,对吧?这一切都发生在内部,因此用户认为该地址是“真实”资源的地址?
谢谢。
I have read many posts and blogs about rewriting and I know there is a difference between internal server rewriting and redirecting. I am interested in knowing how the internal rewriting works, and how this is done in Java. I am using PrettyFaces for my Java webapplication and it would have been great to know how (in very simple terms ofcourse) your able to look at the request before it is served. Is it a kind of filter that is invoked first?
And last, url rewriting on server is "program" that converts a URL in the rewrite rules to a real resource on the server right? This all happens internally so the user thinks that the address is for a "real" resource?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,有一个 Servlet Filter 注册为在任何 ServletRequest 中首先触发。此过滤器拦截请求并重定向、转发或链接(不执行任何操作。)
这要看情况。如果您使用重定向,那么用户就会知道他们已被移动到不同的资源。然而,使用 PrettyFaces 的默认映射功能,而是使用 servlet Forward。这对外部用户完全隐藏。
PrettyFaces 和 OCPsoft Rewrite 等工具所做的另一件事是出站 URL 重写,这只能通过“内部服务器”重写工具。这意味着他们还可以修改应用程序 HTML 响应中的 URL(这可以防止生成不正确的链接并将其作为文本发送给用户。)
我希望这是一个有用的总结。
Yes, there is a Servlet Filter registered to trigger first in any ServletRequest. This filter intercepts the request and either redirects, forwards, or chains (does nothing.)
That depends. If you use redirecting, then the user would know they have been moved to a different resource. However, using the default mapping functionality of PrettyFaces, a servlet Forward is used instead. This is completely hidden from external users.
One other thing that tools like PrettyFaces and OCPsoft Rewrite do, is outbound URL-rewriting, which is only possible with "internal server" rewriting tools. This means that they can also modify the URLs in your application's HTML response as well (which prevents incorrect links from being generated and sent to the user as text.)
I hope this is a helpful summary.