[英]IIS7 URL Rewrite with Regex
I'm trying to do a URL rewrite when a user accesses a certain URL of my site: 当用户访问我网站的某个URL时,我正在尝试重写URL:
Accessed URL: https://client1.domain.com
Rewritten URL: https://new-client1.otherdomain.com
My site has many URLs that point to it, so the simple HTTP redirect module will not be a valid solution for this. 我的网站上有许多指向它的URL,因此简单的HTTP重定向模块将不是有效的解决方案。 What would the Regex be and what would I want to fill in for each section in a rewrite rule? 正则表达式将是什么,我想为重写规则的每个部分填写什么?
Thanks 谢谢
尝试这个:
s/client1.domain/new-client1.otherdomain/g
You can use this regex pattern to search for client1.domain
in order to replace it: 您可以使用此正则表达式模式搜索client1.domain
来替换它:
(?<=//)([^.]+)\.domain
Replace it with a backreference to client1
and the new domain like so: 将其替换为对client1
和新域的向后引用,如下所示:
$1\.otherdomain
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.