IIS – 一个域名下的两个站点 – 实现的最佳方法?

huangapple go评论63阅读模式
英文:

IIS - two sites under one domain - best way to achieve this?

问题

我在StackOverflow上阅读了很多文章和问题。但我不太确定哪种解决方案适合我的需求。

我在IIS中有两个站点。
https://example.com

https://career.example.com

两者在同一台服务器上具有不同的物理路径。它们使用不同的CMS,并且是不同的网站。

我希望子域站点在子文件夹下访问:
https://example.com/career/

这些子文件夹也应该在新路径下可用。

例如,
https://career.example.com/job1
应该是
https://example.com/career/job1

解决方案从在子域站点的站点中进行简单的重定向,到虚拟目录,或者更改绑定并在主域下添加新绑定的方式都有...

我不确定应该选择哪种方式。

您建议采用哪种解决方案?

英文:

I read a lot articles and questions here on stackoverflow.
But I am not quite sure which solution fits my needs.

I have a two sites in IIS.
https://example.com
and
https://career.example.com

Both have different physical paths on the same server. Both use different CMS and are websites.

I want the subdomain site to be accessed under a subolder instead:
https://example.com/career/

The subfolders also should be available under the new path.

e.g.
https://career.example.com/job1
should be
https://example.com/career/job1

The solutions go from simple redirects in the site of the subdomain, to virtual directories, or changing bindings and adding new ones under the main domain....

I am not sure which way to go.

Do you recommend a solution?

答案1

得分: 1

如果您希望通过子目录而不是子域名访问子域站点,也就是说,当您在浏览器地址栏中输入 https://example.com/career/job1 时,您实际访问的网页内容是 https:/ /career.example.com/job1。如果我理解有误,请纠正我。

要实现这一点,您需要使用反向代理、URL 重写和应用程序请求路由。具体的实施步骤如下:

  1. 您需要在 IIS 中启用反向代理。如果尚未安装 ARR 模块,您需要首先下载并安装它。

  2. 然后,您需要在 https://example.com 站点下添加反向代理重写规则。在 web.config 文件中的规则如下:

您可以参考这个文档以了解更多关于反向代理、URL 重写和 ARR 的信息:

文档链接

英文:

If you want the subdomain site to be accessed under a subolder instead, that is, when you go to the URL like https://example.com/career/job1 in the browser address bar, the content of the webpage you actually access is https:/ /career.example.com/job1. Please correct me if I understand wrong.

To achieve this, you need to use Reverse Proxy with URL Rewrite and Application Request Routing. The specific implementation steps are as follows:

  1. You need to enable reverse proxy in IIS. If you have not installed the ARR module, you need to download and install it first.

IIS – 一个域名下的两个站点 – 实现的最佳方法?

  1. Then you need to add reverse proxy rewrite rules under https://example.com site. The rule in web.config as follow:

IIS – 一个域名下的两个站点 – 实现的最佳方法?

You can refer to this document to learn more about Reverse Proxy with URL Rewrite and ARR.

huangapple
  • 本文由 发表于 2023年6月29日 15:40:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76578974.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定