确保文件夹名称不会出现在域名中

发布于 2024-09-24 12:41:58 字数 458 浏览 3 评论 0原文

我们的托管帐户是通过域名 www.nashman.ca 设置的,我们的应用程序位于 www.nashman.ca/hub。我们还有另一个域名转发到 www.nashman.ca/hub,那就是 hub.mhn.co。我遇到的问题是,每当您从 hub.mhn.co 导航到另一个页面时,转发的域都会添加到 /hub 上,因此当您进入时,该域显示为 hub.mhn.co/hub/admin例如,管理区域。我需要域名保持一致,并且永远不要显示该文件夹名称,因为它破坏了我使用的一些 JavaScript。设置此功能的最佳方法是什么?

编辑

我一直在阅读一些有关 URL 重写的内容,并对其进行研究 - 我的托管提供商支持 IIS7 URL 重写模块。到目前为止,我找到的所有教程都详细介绍了如何使用 IIS 配置工具设置规则,但我无权访问它们。有没有办法通过编辑应用程序根目录中的 web.config 来做到这一点?这能解决我的问题吗?

our hosting account is set up with the domain www.nashman.ca, and our application is at www.nashman.ca/hub. We have another domain that forwards to www.nashman.ca/hub and that's hub.mhn.co. The problem i'm having with this is that the forwarded domain adds on the /hub whenever you navigate to another page from hub.mhn.co, so the domain shows as hub.mhn.co/hub/admin when you're in the admin area, for example. I need the domain to stay consistent, and never show that folder name, because its breaking some of the javascript I use. What is the best way to set this up?

edit

I've been doing some reading about URL Rewriting, and looking into it - my hosting provider supports the IIS7 URL Rewrite module. All the tutorials I've found so far detail how to set up rules using the IIS config tools, but I don't have access to them. Is there a way to do it by editing my web.config in my apps root directory? And will this solve my issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白衬杉格子梦 2024-10-01 12:41:58

hub.mhn.co 的默认页面是否使用重定向至 www.nashman.ca?如果是这样,则转发软件基本上会返回浏览器请求的新 URI,并且新 URI 将替换浏览器窗口中的旧 URI,从而替换所有未来的请求。您可能会重定向到 ~/hub/ (站点根目录的 hub 子目录),这将导致浏览器请求一个新的 URI,该 URI 保留域名但附加子目录。

如果您可以直接控制 DNS 和 Web 服务器,则可以使用 DNS 配置将对 hub.mhn.co 域的请求直接定向到 Web 服务器的 /hub 子目录。这样,浏览器永远不会知道 hub.mhn.co 实际上是 www.nashman.ca/hub/。您可能必须定向到网络服务器上的备用端口并将该端口映射到子目录,具体取决于您的 DNS 软件(IIRC,大多数可以处理 ipaddress/subdir 路由,但有些只能处理到 ipaddress:port 的路由)。

如果您的 IT 部门对您的 DNS 路由或确切的托管环境没有直接控制/所有权,那么您或多或少会受到托管提供商的摆布。他们可能能够设置自己的环境来做同样的事情,也可能不能;你所能做的就是询问。

编辑:如果您是远程托管并且无法使用其 DNS 静默重新路由,那么基本上您还有两个选择。

第一个选项:在托管环境中的不同根空间下将 nashman.ca/hub 的 Web 层克隆(复制所有文件)为 hub.mhn.co(尝试将服务层代码的任何挂钩保留在 nashman 上,以便您不必复制整个垂直切片)。如果您还必须将 UI 保留在 /hub/ 子目录下,那么您就是在重复代码,但您可以通过部署脚本来缓解这种情况,该脚本允许您将代码库的一个本地副本部署到各个位置。这也可能会花费更多,因为您的托管环境现在正在托管两个重要的站点。

第二种选择:托管站点和/或在您自己的硬件上解决呼叫。只要您通过 ISP 拥有公共静态 IP 地址,您就可以提供一个 DNS 服务器,该服务器将成为 nashman.ca 和 hub.mhn.co 域的“权威”服务器。您的 ISP 或第三方域名注册管理机构可以提供“向下传递”路由,以便将来自 TLD 服务器的请求传递给您。然后,您可以将请求路由到您喜欢的任何 IP 地址、端口和/或子文件夹;可以是远程网络托管提供商(只要他们不介意托管您的网站)或您自己的网络服务器。这需要硬件以及 ISP 提供的静态 IP。如果该服务器断电,则在电源恢复之前将无法访问您的站点。如果您的 DNS 服务器的 IP 地址发生更改,则 DNS 将无法访问您的站点,直到将请求路由到您的服务器使用新 IP 更新其路由表(最长可能需要 24 小时)。

Is the default page for hub.mhn.co using a redirect to www.nashman.ca? If so, what is happening is that the forwarding software basically returns a new URI that the browser requests, and the new URI will replace the old one in the browser window and thus in all future requests. You're probably redirecting to ~/hub/ (the hub subdirectory of the site root) which will result in the browser requesting a new URI that keeps the domain name but tacks on the subdirectory.

If you have direct control over the DNS and your webservers, you can use the DNS configuration to direct a request for the hub.mhn.co domain directly to the /hub subdirectory of your webserver. That way, the browser never knows that hub.mhn.co is actually www.nashman.ca/hub/. You might have to direct to an alternate port on the webserver and map that port to the subdirectory, depending on your DNS software (IIRC, most can deal with ipaddress/subdir routes, but some can only handle routing to ipaddress:port).

If your IT department does not have direct control/ownership over your DNS routing, or your exact hosting environment, you are more or less at the mercy of your hosting provider. They may be able to set up their environment to do the same thing, or not; all you can do is ask.

EDIT: Basically you have two options left if you're hosting remotely and can't use their DNS to reroute silently.

First option: clone (copy all files from) the web layer of nashman.ca/hub as hub.mhn.co under a different root space in your hosting environment (try to keep any hooks to service-layer code over at nashman so you don't have to copy the whole vertical slice). If you must also keep the UI under the /hub/ subdirectory, you're repeating code, but you may be able to mitigate this with deploy scripts that will allow you to deploy one local copy of your codebase to various locations. This may also cost more as your hosting environment is now hosting two non-trivial sites.

Second option: host the site and/or resolve the calls on your own hardware. As long as you have a public, static IP address through your ISP, you can provide a DNS server that will be the "authoritative" server for nashman.ca and hub.mhn.co domains. Your ISP or a third party domain name registry can provide a "pass-down" route to get requests from the TLD servers down to you. Then, you can route requests to whatever IP address, port and/or subfolder you like; that can be a remote webhosting provider (as long as they don't mind JUST hosting your site) or your own webservers. This will require the hardware, and a static IP from your ISP. If you lose power to this server, your site will be unreachable until power's restored. If the IP address of your DNS server changes, your site will be unaccessible by DNS until the server that routes requests to you updates its routing table with the new IP (which can be up to 24 hours).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文