在 URL 中隐藏网站文件名
我想隐藏网址中的网页名称,只显示域名或域名的一部分。
例如:
我有一个名为“MyWebSite”的网站。网址为:localhost:8080/mywebsite/welcome.xhtml。我只想显示“localhost:8080/mywebsite/”。
但是,如果页面位于 localhost:8080/mywebsite/restricted/restricted.xhtml,那么我想显示 localhost:8080/mywebsite/restricted/。
我相信这可以在 web.xml 文件中完成。
I would like to hide the webpage name in the url and only display either the domain name or parts of it.
For example:
I have a website called "MyWebSite". The url is: localhost:8080/mywebsite/welcome.xhtml. I would like to display only the "localhost:8080/mywebsite/".
However if the page is at, for example, localhost:8080/mywebsite/restricted/restricted.xhtml then I would like to display localhost:8080/mywebsite/restricted/.
I believe this can be done in the web.xml file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信你想要 URL 重写。查看此链接:http://en.wikipedia.org/wiki/Rewrite_engine - 有URL 重写的方法有很多,您需要决定哪种方法适合您。有些方法确实使用了 web.config 文件。
I believe that you want URL rewriting. Check out this link: http://en.wikipedia.org/wiki/Rewrite_engine - there are many approaches to URL rewriting, you need to decide what is appropriate for you. Some of the approaches do make use of the web.config file.
您可以通过多种方式做到这一点。我看到最多的是有一个称为重写引擎的“前门”,它动态解析 URL 以在内部重定向请求,而不会暴露有关如何发生的详细信息,就像您使用简单的查询字符串等时看到的那样。允许将您指定的 URL 消化为对具有特定内容的母版页的请求,而不仅仅是在该位置查找要提供服务的物理页面。
StackExchange 站点这样做是为了让您能够以半永久的方式链接到某个问题(因此可以使用带有记录这些 URL 的爬虫的搜索引擎),而不必在文件系统中为每个问题拥有一个真实的页面。被问过(截至目前,我们已收到多达 9,387,788 个问题)。
You can do this in several ways. The one I see most is to have a "front door" called a rewrite engine that parses the URL dynamically to internally redirect the request, without exposing details about how that might happen as you would see if you used simple query strings, etc. This allows the URL you specify to be digested into a request for a master page with specific content, instead of just looking up a physical page at that location to serve.
The StackExchange sites do this so that you can link to a question in a semi-permanent fashion (and thus can use search engines with crawlers that log these URLs) without them having to have a real page in the file system for every question that's ever been asked (we're up to 9,387,788 questions as of this one).