简体   繁体   中英

IIS7 URL Rewrite with Regex

I'm trying to do a URL rewrite when a user accesses a certain URL of my site:

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. 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:

(?<=//)([^.]+)\.domain

Replace it with a backreference to client1 and the new domain like so:

$1\.otherdomain

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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