IIS7 URL 重写出站规则
由于某种原因,我似乎无法理解这些重写规则,我希望你们能提供帮助。我想要的是一个出站规则,它将重写链接、img、脚本和输入标签的路径。
我想更改此设置: http://www.mysite.com/appname/css/file .css
为此:http://cdn.mysite.com/css/file。所以
,基本上我需要交换主机名并删除URL 中的应用程序名称。我已经设置了 *.aspx 文件的前置条件过滤器,但其余的对我来说似乎是希腊语。
编辑清楚
上面 URL 中的应用程序名称是 IIS 中的应用程序。它是正在使用的任何应用程序名称的占位符。它可以是我们当前设置的 50 多个不同应用程序中的任何一个。 总是有一个应用程序名称。也许这会让规则变得更加容易。
主机名(在本例中为 www.mysite.com)在子域方面也可能略有不同。它可能是 www1.mysite.com、www2 等。另外,我刚刚意识到我需要维护 SSL(如果存在)。
所以,我想归根结底,我只需要获取 URL,减去应用程序名称,并将其附加到新域,同时尊重所使用的协议。
原始 URL:http(s)://{host}/{appname}/{URL}
输出:http(s)://cdn.mysite.com/{URL}
I can't seem to get my head around these rewrite rules for some reason and I was hoping you guys could help. What I want is an outbound rule that will rewrite paths for link, img, script, and input tags.
I want to change this: http://www.mysite.com/appname/css/file.css
To this: http://cdn.mysite.com/css/file.css
So, basically I need to swap the host name and drop the app name from the URL. I've got the pre-condition filters to *.aspx files set already, but the rest seems like Greek to me.
EDIT for clarity
The appname in the URL above is an application in IIS. It's a placeholder for whatever appname happens to be in use. It could be any of over 50 different apps with our current setup. There will ALWAYS be an appname. Perhaps that will make the rule even easier.
The hostname, in this case www.mysite.com, can also vary slightly in terms of the subdomain. It might be www1.mysite.com, www2, etc. Also, just realized that I need to maintain the SSL if there.
So, I guess when it comes down to it, I really just need to take the URL, minus the appname, and append it to the new domain, while respecting the protocol that was used.
Original URL: http(s)://{host}/{appname}/{URL}
Output: http(s)://cdn.mysite.com/{URL}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您的网站域始终相同,那么此规则应该执行:
编辑:根据澄清的问题进行更改
我假设子域(www、www2、...)始终存在,并且必须在目标网址中忽略。
I assume your website domain is always the same, then this rule should do:
EDIT: changed according to clarified question
I assume the subdomain (www, www2, ...)is always there and it has to be ignored in target url.