简体   繁体   English

Url 将第一个路径段重写为子域

[英]Url rewrite first path segment to subdomain

I'm trying to do the below with a rewrite.我正在尝试通过重写来执行以下操作。 From my attempts so far, it doesn't appear possible since I don't think I have access to rewrite the host.从我到目前为止的尝试来看,这似乎是不可能的,因为我认为我无权重写主机。

domain.com/sub/web/mypage needs to become sub.domain.com/web/mypage domain.com/sub/web/mypage需要变成sub.domain.com/web/mypage

Essentially trying to do the opposite of this: URL Rewrite city.domain.com to domain.com/city基本上试图做相反的事情: URL Rewrite city.domain.com to domain.com/city

Was hoping to figure out a rewrite or something so I don't have to spend weeks fixing routes in a legacy webforms application that's very coupled to the expected subdomain url pattern.希望找出重写或其他方法,这样我就不必花费数周时间来修复与预期子域 url 模式非常耦合的旧版 webforms 应用程序中的路由。

My thought was to rewrite on a proxy server and send to the server farm with the "old" subdomain url and it would maybe "just work".我的想法是在代理服务器上重写并使用“旧”子域 url 发送到服务器场,它可能“正常工作”。

在此处输入图片说明

Do you want to redirect from https://doman.com/sub/web/mypage to https://sub.domain.com/web/mypage ?您想从https://doman.com/sub/web/mypage重定向到https://sub.domain.com/web/mypage吗? if so, you can try this rule:如果是这样,你可以试试这个规则:

<rule name="test1" stopProcessing="true">
   <match url="(.*)" />
      <conditions>
           <add input="{HTTP_HOST}" pattern="^domain.com$" />               
           <add input="{HTTPS}" pattern="on" />
           <add input="{REQUEST_URI}" pattern="^/sub/web/mypage" />
      </conditions>
   <action type="Rewrite" url="https://sub.domain.com/web/mypage" logRewrittenUrl="true" />
</rule>

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

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