Reputation: 16519
We've moved our site from a php apache site to an asp.net mvc site and I'm trying to get specific redirects to work but am getting stuck.
Basically I want any request for http://www.mysite.com/index.php?pr=about_us to be redirected to http://www.mysite.com/About-Us
I've tried this but it doesn't work. Any ideas?
<rewrite>
<rules>
<rule name="About Us" stopProcessing="true">
<match url="index.php?pr=About_Us" ignoreCase="false" />
<action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>
</rules>
</rewrite>
I've also tried this but it didn't work either.
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Permanent">
<add wildcard="index.php?pr=About_Us" destination="/About-Us" />
</httpRedirect>
I've got about a dozen of these specific redirects that I need to implement to various pages.
Any help is greatly appreciated! Thanks
Upvotes: 2
Views: 8308
Reputation: 102723
Try this one:
<rule name="About Us" stopProcessing="true">
<match url="^(.*)$">
<conditions>
<add input="{URL}" pattern="index.php?pr=About_Us" />
</conditions>
</match>
<action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>
Edit
This is another possibility for the conditions:
<conditions logicalGrouping="MatchAll">
<add input="{QUERY_STRING}" pattern="?pr=About_Us" />
<add input="{REQUEST_FILENAME}" pattern="index.php" />
</conditions>
Edit - Working Solution
<rule name="About Us" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{QUERY_STRING}" pattern="/?pr=About_Us$" />
<add input="{REQUEST_FILENAME}" pattern="index.php" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>
Upvotes: 3