Quantcast
Channel: URL Rewrite Module
Viewing all articles
Browse latest Browse all 2482

Replace patterns in URLs

$
0
0

We have a need on one of our Web properties to move content from one location to another. The result will be a different portion of a URL for all content in the folder. Basically, what I want to do is redirect:

http://www.mydomain.com/folderA/folderB/folderC/f/1234.aspx

to

http://www.mydomain.com/folderA/folderD/folderE/f/1234.aspx

IOW, "replace" /folderB/folderC/ in that URL with /folderD/folderE/. There will be other patterns like that, too. For example, redirect:

http://www.mydomain.com/folderA/folder1/f/abcd

to

http://www.mydomain.com/folderA/folder2/folder3/f/abcd

I am aware of IIS' redirect module and would like to use that for the purpose of minimizing "broken links" on our Web site. I have done some research on the topic but have not gotten the "recipe" for the regular expression to use for this. What I have tried is

<rules><rule name="communities-test" stopProcessing="true"><match url="^/folderA/folderB/folderC/(.*)"/><action type="Redirect" url="/folderA/folderD/folderE/{R:0}" appendQueryString="true" redirectType="Found" /></rule></rules>

but what that did was append the "new folders" to the existing one, resulting in

http://www.mydomain.com/folderA/folderB/folderC/f/1234.aspx

becoming

http://www.mydomain.com/folderA/folderB/folderC/folderA/folderD/folderE/f/1234.aspx

which is not what I am going for. I also tried

<rule name="communities-test" patternSyntax="ECMAScript"><match url="/folderA/folderB/folderC/" /><conditions><add input="{HTTP_HOST}" pattern="www.mydomain.com" /><add input="{QUERY_STRING}" pattern="(.*)/folderA/folderB/folderC/(.*)" /></conditions><action type="Rewrite" url="{R:0}?{C:1}/folderA/folderD/folderE/{C:2}" appendQueryString="false" /></rule>

which did not work at all. Changing type="Rewrite" to type="Redirect" also did not work. I have to be doing something really stupid (it's quite all right to tell me I am... :) Looking for any hints or suggestions on how to get this to work.


Viewing all articles
Browse latest Browse all 2482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>