Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to create a rewrite rule to 301 redirect a page to a location in a subfolder, hut it seems like I get infinite redirects with my code.
Anyone can help me

What I have tried:

<rule name="Redirect3" stopProcessing="true">
	<match url="mypage" />
    <action type="Redirect" url="mydomain/mysubfolder/mypage/" redirectType="Permanent" />
</rule>
Posted
Updated 6-Apr-23 1:34am

URL Rewrite Module Configuration Reference | Microsoft Learn[^]

The default pattern syntax for <match> is a JavaScript-style regular expression. Your rule will match any URL which contains the string mypage. Since the URL you're redirecting to includes that string, that URL will also be redirected.

If you want to redirect requests where the path starts with "mypage", then use an anchor:
XML
<match url="^/mypage" />
 
Share this answer
 
found out it is actually without the slash

so correct is <match url="^mypage">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900