简体   繁体   English

重定向IIS / Azure中的虚拟目录

[英]Redirect a virtual directory in IIS / Azure

I currently have two asp.net mvc websites hosted on a single azure web service: - domain.com/ - domain.com/app/ 我目前有两个asp.net mvc网站托管在一个单一的蔚蓝Web服务: - domain.com/ - domain.com/app/

I have a virtual directory /app 我有一个虚拟目录/app

I want to now combing the two sites functionalities into one, and then host it in the root directory. 我现在想将两个站点功能合并为一个,然后将其托管在根目录中。 However I don't want to break existing links out there. 但是我不想破坏现有的链接。

How can I make it so that any request to `domain.com/app/anything' gets redirected to 'domain.com/anything' 我该如何做,以便将对“ domain.com/app/anything”的任何请求重定向到“ domain.com/anything”

You didn't clarify what technology you are using for your websites. 您没有弄清楚您的网站使用什么技术。 What you basically need is URL rewrite module. 您基本上需要的是URL重写模块。 You can deploy in your web.config something like this: 您可以在web.config中部署以下内容:

 <rewrite> <rules> <rule name="RedirectToRoot" stopProcessing="true"> <match url="^app/(.*)" /> <action type="Redirect" url="{R:1}" redirectType="Permanent"/> </rule> </rules> </rewrite> 

According to your scenario, you could leverage URL Rewrite Module to achieve your purpose. 根据您的方案,您可以利用URL重写模块来实现您的目的。 In order to do this, you need to migrate the functionalities of your website under the virtual directory into the root website, then configure the URL rewrite module under the system.webServer section of your root web.config. 为此,您需要将虚拟目录下的网站功能迁移到根网站,然后在根web.config的system.webServer部分下配置URL重写模块。 Also, you need to remove all the files under the virtual directory when you deployed your root website. 另外,在部署根网站时,您需要删除虚拟目录下的所有文件。 For more details about URL Rewrite Module, you could refer to Creating Rewrite Rules for the URL Rewrite Module and Using the URL Rewrite Module . 有关URL重写模块的更多详细信息,请参考为URL重写模块创建重写规则使用URL重写模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM