典型的域映射要求
Typical domain mapping requirement
我有一个托管到根域的网站 www.example.com。我可以按如下方式进行映射吗-
www.example.com/portal1 mapped to www.portal1.com
www.example.com/poral2 mapped to www.portal2.com
www.example.com/portal1/product/product1-> www.portal1.com/product/product1
www.example.com/portal2/product/product1-> www.portal2.com/product/product1
请注意,左侧提到的所有网址均正常工作(映射已完成)。门户是可变的,因此可以有 n 个这样的门户。
在此先感谢您的帮助
您不能使用 DNS 服务器进行以下映射,这些服务器仅处理域名。
例如www.example.com -> www.portal2.com 或 example.com -> www.example.com
但您可以使用 301 redirects 进行此映射。
这个question有点像。
在 Tomcat 中创建一个空的 ROOT
上下文(其中没有任何已部署的应用程序)。在你的webapps目录下放一个context.xml
文件,在ROOT/META-INF
下面,内容如下
<?xml version='1.0' encoding='UTF-8'?>
<Context docBase="ROOT" path="/" reloadable="true" crossContext="true">
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
</Context>
在 ROOT/WEB-INF
目录中也设置一个 rewrite.config
文件,其中包含此内容
RewriteCond %{HTTP_HOST} ^www.portal1.* [NC]
RewriteRule ^/(.*)$ /portal1/ [L]
RewriteCond %{HTTP_HOST} ^www.portal2.* [NC]
RewriteRule ^/(.*)$ /portal2/ [L]
是的。您可以通过 URL 重写 web/application 级别进行重定向,例如 IIS URL 重写,Apache.
我花了很多时间才最终得出我正在寻找的解决方案。大多数给出的答案都是部分正确的。但是这个需求很典型,我已经通过以下方式解决了。
我开发了一个 servlet,它检查主机名(有效的主机名保存在数据库中)和有效的 url 模式并进行适当的路由。 (服务器端路由)。这还包括检查进一步的路由是如何发生的,比如如果有人访问 www.porta1.com 并单击 link 他应该登陆 www.portal1.com/aboutus.
我知道很多艰苦的工作,但工作正是需要的。
我有一个托管到根域的网站 www.example.com。我可以按如下方式进行映射吗-
www.example.com/portal1 mapped to www.portal1.com
www.example.com/poral2 mapped to www.portal2.com
www.example.com/portal1/product/product1-> www.portal1.com/product/product1
www.example.com/portal2/product/product1-> www.portal2.com/product/product1
请注意,左侧提到的所有网址均正常工作(映射已完成)。门户是可变的,因此可以有 n 个这样的门户。
在此先感谢您的帮助
您不能使用 DNS 服务器进行以下映射,这些服务器仅处理域名。 例如www.example.com -> www.portal2.com 或 example.com -> www.example.com
但您可以使用 301 redirects 进行此映射。
这个question有点像。
在 Tomcat 中创建一个空的 ROOT
上下文(其中没有任何已部署的应用程序)。在你的webapps目录下放一个context.xml
文件,在ROOT/META-INF
下面,内容如下
<?xml version='1.0' encoding='UTF-8'?>
<Context docBase="ROOT" path="/" reloadable="true" crossContext="true">
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
</Context>
在 ROOT/WEB-INF
目录中也设置一个 rewrite.config
文件,其中包含此内容
RewriteCond %{HTTP_HOST} ^www.portal1.* [NC]
RewriteRule ^/(.*)$ /portal1/ [L]
RewriteCond %{HTTP_HOST} ^www.portal2.* [NC]
RewriteRule ^/(.*)$ /portal2/ [L]
是的。您可以通过 URL 重写 web/application 级别进行重定向,例如 IIS URL 重写,Apache.
我花了很多时间才最终得出我正在寻找的解决方案。大多数给出的答案都是部分正确的。但是这个需求很典型,我已经通过以下方式解决了。
我开发了一个 servlet,它检查主机名(有效的主机名保存在数据库中)和有效的 url 模式并进行适当的路由。 (服务器端路由)。这还包括检查进一步的路由是如何发生的,比如如果有人访问 www.porta1.com 并单击 link 他应该登陆 www.portal1.com/aboutus.
我知道很多艰苦的工作,但工作正是需要的。