Question

Is it possible to have one URL rewrite rule for an entire set of related URLs that match a pattern? I'm trying to create a URL rewrite rule in my web config file that takes a specific matched pattern and then redirects the entire URL, but only changes the specific portion of the URL that is matched. For example, could 1 URL rewrite rule accomplish this:

http://www.something.com/local-pages/my-site

http://www.something.com/local-pages/my-site/page-one

http://www.something.com/local-pages/my-site/page-two

http://www.something.com/local-pages/my-site/page-three

And for each of these requests, redirect the whole thing, changing only the segment that was matched "my-site" to "your-site?"

http://www.something.com/local-pages/your-site

http://www.something.com/local-pages/your-site/page-one

http://www.something.com/local-pages/your-site/page-two

http://www.something.com/local-pages/your-site/page-three

Was it helpful?

Solution

This is what I was looking for:

<rule name="myRule" stopProcessing="true">
<match url="local-pages/my-site/(.*)" />
<action type="Redirect" url="local-pages/your-site/{R:1}" redirectType="Permanent" />

OTHER TIPS

Yes the rule would look something like this:

RewriteEngine On
RewriteRule /local\-pages/my\-site(.*)$ /local-pages/your-site$1 [R=301,L,QSA,NC]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top