Mask URL to subdomain using IIS

不打扰是莪最后的温柔 提交于 2019-12-11 13:30:47

问题


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

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.

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).


回答1:


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

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.

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.

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

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



来源:https://stackoverflow.com/questions/20599307/mask-url-to-subdomain-using-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!