根据子域名/域名更改索引页面
问题和我的想法很模糊,因为我仍处于设计阶段。我只是想知道一些可以在问题上抢占先机的信息,以及如何/在哪里继续解决它。
问题部分:
有一个使用 struts-2 JSP/servlet 构建的 Web 应用程序,其 URL 为 mywebapp.com
。 要求是每个客户端都可以使用其子域访问此 mywebapp.com
,例如 webapp.abc.com、
myapp.xyz.com 等我必须根据域名进行过滤,为他们提供定制的登录页面。我已将他们的域名保存在数据库中,以映射需要在自定义登录页面上显示的详细信息。
我的想法是他们会将 mywebapp.com
的 IP 地址提供给他们的子域注册表,以便它将登陆 mywebapp.com
但从这里,我如何过滤自定义登录页面的域/子域?
任何可能的开始方式都将受到赞赏。
Problem and my idea on it is just vague as I'm still in design phase. I just wanted to know something to get a head start on the problem and how/where to proceed to solve it.
Problem Part:
There's one web app built using struts-2 JSP/servlet, with the URL mywebapp.com
.
The requirement is every client can access this mywebapp.com
using their subdomain, like webapp.abc.com,
myapp.xyz.com,
etc. I have to filter based on the domain name to give them a customized login page. I have saved their domain name in the database to map their details that need to be displayed on customized login page.
What I have thought is they will give the IP address of mywebapp.com
to their subdomain registry so it will land on mywebapp.com,
but from here, how can I filter the domain/subdomain for a customized login page?
Any possible way to start on this will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用过滤器。使用过滤器,您可以独立于控制器处理对应用程序的任何请求。
例如,如果您想根据子域重定向到不同的页面,您的过滤器可以管理它,或者作为在控制器调用之前或在控制器调用之后处理的过滤器。
更新:有更多关于 Struts 2 拦截器的文档,它们可以用于类似的目的:http://java.dzone.com/articles/struts2-tutorial-part-57
如果从数组末尾开始,您知道倒数第二个始终是第二个- 级域 (SLD),倒数第三个是第三级子域。
I would suggest using a Filter. With a filter, you can process any requests to your application independent of the controllers.
For instance, if you wanted to redirect to a different page based on subdomain, your filter could manage this, either as a filter that processes before the controller call or after the controller call.
UPDATE: There is more documentation on Struts 2 Interceptors, which can serve a similar purpose: http://java.dzone.com/articles/struts2-tutorial-part-57
If you start from the end of the array, you know that the 2nd to last is always the second-level domain (SLD) and the 3rd from last is where the third level subdomains will be.