Zapnologica
Zapnologica

Reputation: 22556

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/

I have a virtual directory /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'

Upvotes: 0

Views: 1545

Answers (2)

Bruce Chen
Bruce Chen

Reputation: 18465

According to your scenario, you could leverage URL Rewrite Module to achieve your purpose. 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. 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.

Upvotes: 1

albattran
albattran

Reputation: 1907

You didn't clarify what technology you are using for your websites. What you basically need is URL rewrite module. You can deploy in your web.config something like this:

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

Upvotes: 1

Related Questions