使用IIS将URL掩盖到子域 [英] Mask URL to subdomain using IIS

查看:135
本文介绍了使用IIS将URL掩盖到子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用子域掩盖或隐藏URL。

I am looking to mask or cloak a URL with a subdomain.

例如,如果我有URL http://example.com/news/article/this-is-an-article 可以访问< a href =http://test.example.com/this-is-an-article =nofollow> http://test.example.com/this-is-an-article 和将显示相同的页面。注意:所需的辅助URL是原始URL的子域。

For example, if I have the URL http://example.com/news/article/this-is-an-article it would be possible to visit http://test.example.com/this-is-an-article and the same page would display. Notice: the desired secondary URL is a subdomain of the original URL.

我正在使用IIS 7.我查看过的所有示例只更改了现有的结构URL(而不是将其映射到子域)。我正在寻找与重定向不同的东西(也许是重写,如果这是正确的术语)。

I am using IIS 7. All of the examples I have looked at only change the structure for the existing URL (instead of mapping it to a sub-domain). I am looking for something different to a redirect (perhaps a rewrite, if that is the correct term).

推荐答案

假设你是使用IIS重写模块,有两种主要的响应类型:重写和重定向。

Assuming you are using the IIS rewrite module, there are two main response types: Rewrite and Redirect.

重写获取现有网址并在内部更改同一站点,以便站点上不存在的URL重新映射到现有端点。用户没有注意到差异,请求的url返回预期的内容。这仅适用于网站。

A rewrite takes the existing url and changes it internally within the same site, so that a url that doesn't really exist on the site is remapped to an existing endpoint. The user does not notice the difference, the requested url returns the expected content. This only works within a site.

当您需要从其他网站(例如您的网站)返回内容时,会使用重定向 。不是在内部重写url,而是将具有新url的301或302返回给浏览器。浏览器不仅仅是请求新的URL并从第二个站点获取内容。用户会注意到地址栏中url的更改。

A redirect is used when you need to return content from a different site (such as in your case). Instead of rewriting the url internally, a 301 or 302 with a new url is returned to the browser. The browser than just requests that new url and gets the content from the second site. The user will notice a change of the url in the address bar.

所以你必须在重写模块中使用重定向响应类型,只有在这种情况下你可以指定绝对网址,例如 http://example.com/news/article/this- is-an-article

So you have to use the redirect response type in the rewrite module, only in this case you can specify an absolute URL such as http://example.com/news/article/this-is-an-article

如果exam​​ple.com和test.example.com都映射到同一个IIS站点,则可以使用重写规则。

If both example.com and test.example.com are mapped to the same IIS site, you could use a rewrite rule.

这篇关于使用IIS将URL掩盖到子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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