3

So I have one simple problem but somehow doesnt seem to work. I have one URL http://www.domain.com/%20#axzz2ZX4J0KAS which I want to redirect to http://www.domain.com/page-name.htm. I have tried so many combinations in IIS URL Rewrite/web.config and they all seem to work inside test pattern dialog but none works in browsers.

1.

<rule name="Redirect%20InHomePage" enabled="true" stopProcessing="true">
    <match url="^(.+)domain\.com/(\s|%20)(.+)" ignoreCase="true" />
    <action type="Redirect" url="http://www.domain.com/page-name.htm" />
</rule>

2.

   <match url="(.+)/%20(.+)" ignoreCase="true" />

3.

    <match url="(.+)domain.com/ (.+)" ignoreCase="true" />

4.

   <match url="(.+)domain.com/(\s|%20)(.+)" ignoreCase="true" />

As you can see I tried all of above patterns, they all work fine in Test Pattern dialog but when i browse URL, it always converts %20 to space and rule doesn't work for redirect.

Please help me for this simple yet unsolved problem, if anyone knows what am I missing.

user704988
  • 436
  • 1
  • 9
  • 24
  • Note: #axzz2ZX4J0KAS is appended on all URLs by a JS plugin used which is out of my control. site admin can stop using it anyday and it will stop appending #axzz2ZX4J0KAS after all URLs. – user704988 Jul 19 '13 at 23:24

2 Answers2

4

I was having a similar issue and got it to work by typing spaces " " instead of %20 for my rules.

So here you may want to try [ ] for your space.

https://i.stack.imgur.com/N1Tmh.jpg

lathomas64
  • 1,612
  • 5
  • 21
  • 47
  • its hard to tell but there is a space between \. and % although I really can take those two out of this particular rewrite. – lathomas64 Oct 29 '13 at 18:59
0

Don't include the domain name in your match url.

If you want to handle either having the tracking code or not in your url then you probably want to use something like this:

<rule name="RedirectSpaceInHomePage" stopProcessing="true">
  <match url="^\s(#\.*)?$" />
  <action type="Redirect" url="page-name.htm" />
</rule>
emjohn
  • 69
  • 4