具有指向父级子文件夹的多个文件夹的多个域的Web应用程序 [英] Web app with multiple domains pointing to subfolders of a parent one

查看:41
本文介绍了具有指向父级子文件夹的多个文件夹的多个域的Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Boot开发一个应用程序,该应用程序在一个域下运行;

I’m developing an application with Spring Boot, which runs under a domain, let’s say;

parentdomain.com

用户登录后,从一侧从 parentdomain.com/admin 输入其内容。可以说,该内容在子文件夹中进行了处理并可以公开访问;

From one side the users enter their content, after logging in, at parentdomain.com/admin. This content is processed and made publicly accessible at a subfolder, let’s say;

parentdomain.com/user-one-content
parentdomain.com/user-two-content and so on.

我需要将每个用户的域指向他的文件夹,例如:

userone.com should be equivalent to parentdomain.com/user-one-content

导航应保留在userone.com网站上。

The navigation should remain in the userone.com website.

userone.com / first-page应该打开parentdomain.com/user-one-content/first-page。

userone.com/first-page should open parentdomain.com/user-one-content/first-page.

现在该应用已安装在PWS(关键Web服务)上,但是他们的路由系统没有为这种方法提供解决方案,因为多个域指向父级的子文件夹。

Right now the app is installed at PWS (Pivotal Web Services), but their routing system, doesn’t provide a solution to this approach, with multiple domains pointing to subfolders of a parent one.

如何归档此功能?

推荐答案

最后,我可以将其存档,这要感谢 gspatel

At the end I could archive it, thanks to the advice from gspatel

借助PWS的生根系统或其他IaaS云提供商,我可以将每个域都生根到整个应用程序。

With the rooting system of PWS, or other IaaS cloud provider I can root each domain to the whole application.

实施HandleInterceptor的preHandle方法后,我检查请求是否来自我的域( parentdomain.com 在示例中)。或者,如果它来自网站的某个域,则表明该应用正在提供服务(示例中为 userone.com )。在那种情况下,我控制不访问parentdomain.com或其他用户的内容,将请求转发到用户首页( user-one-content 在示例中)。

Implementing the preHandle method of a HandleInterceptor, I check whether the request is coming from my domain (parentdomain.com in the example). Or if it is coming from a domain of the sites, that the app is serving (userone.com in the example). In that case, I control that doesn't access the parentdomain.com, or the content of other users, forwarding the request to the user home page (user-one-content in the example).

这是我的preHadle实现的摘录:

That's an extract, of my preHadle implementation:

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

      ...

      String URI = request.getRequestURI();
      String rootURI = "/" + idweb + "/";

      if(URI.equals("/") || !URI.startsWith(rootURI)){ 
          URI = rootURI;

          RequestDispatcher requestDispatcher = request.getRequestDispatcher(request.getContextPath() + URI);
          requestDispatcher.forward(request, response);

        }

    return true;
}

这篇关于具有指向父级子文件夹的多个文件夹的多个域的Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆