I have a pesky little problem. I am using MVC 3 with rewrite module. There is a link to my website from another website linking to mysite as:
hxxp:www.mysite.com/%20
ie the other site ads %20 (encoded space character) to the end of their url.
Now I need to redirect this link to the main site like so:
hxxp://www.mysite.com/
as otherwise it gives a 404 not found error.
Now the issue I have tried different rewrite rules but nothing seems to redirect the website eg
<rule name="redirect space" stopProcessing="true">
<match url="^hxxp://www.mysite.com/%20" />
<action type="Redirect" url="hxxp://www.mysite.com/" redirectType="Permanent" />
</rule>
and many other combinations, but nothing seems to fix it and it gives 404 errors in every case.
Try to add some variants for the space: encoded one, decoded, and a space character, like this:
<rule name="redirect space" stopProcessing="true">
<match url="^hxxp://www.mysite.com/((%20)|\ |\s)+" />
<action type="Redirect" url="hxxp://www.mysite.com/" redirectType="Permanent" />
</rule>
More information can be found here:
If this still isn't working, you have to write your own rewite module. You can see here a bit more details:
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.