1

I have a site I'm redesigning into Sitecore. The old URLs are at https://[host]/Old/[path(s)]/Pages/[ID].aspx and I want them to be translated to https://[host]/Post/[ID]. I wrote an IIS redirect rule for this that, when I test the URL sample, works to get the [ID] out.

When I put the old URL in, though, I get a Sitecore not found message pointing to the old URL, but it drops the .aspx portion and also, if there's a hyphen in the [ID] it disappears in favor of a space. I did add "/old" URL to the "IgnoreUrlPrefixes" setting in Sitecore, so I thought that would basically keep Sitecore out of it.

My rule definitions:

  • Requested URL matches the pattern, using regular expressions
  • Pattern: ^/(.*)/Pages/(.*).aspx (the pattern tester in IIS reported success)
  • Action type: Redirect (301), to /Post/{R:2}

Any thoughts? Thanks.

  • 2
    Could you provide the rule you wrote? Are you sure it is correct? Normally IIS should handle the request before it is passed to Sitecore. – Alan Płócieniak Nov 3 '16 at 0:24
  • I updated the question with my rule. It tested correctly in IIS at least. Let me ask this also, we're using the Sitecore URL rewrite package as well, but I don't want editors to be able to change these, so I'm putting them in IIS. Could there be some interference there? – Ken McAndrew Nov 3 '16 at 0:34
  • 2
    Are you sure you need the first /? Can you try ^(.*)/Pages/(.*).aspx instead, or I guess it should be ^Old/(.*)/Pages/(.*).aspx? – Søren Kruse Nov 3 '16 at 8:25
  • If you are using a simple IIS rule, you do not need the initial /. If you would move it into a rewrite map though, you do. So, as Søren mentioned, remove the /^ in the beginning. I'll let Søren put it as answer when verified, as he mentioned it first ;) – Gatogordo Nov 3 '16 at 8:32
  • Saren's answer is correct...it's always the little things! Go ahead and put in an answer and I'll accept that one, thanks! :) – Ken McAndrew Nov 3 '16 at 10:12
4

The matching is done on the path after /, so your rule should not start with that.

Try using just ^(.*)/Pages/(.*).aspx instead, or ^Old/(.*)/Pages/(.*).aspx if you need the Old part there as well.

Also, you could probably improve the regex a bit by requiring at least one character in the two wildcard groups and by escaping the . before aspx:

^Old/(.+)/Pages/(.+)\.aspx

| improve this answer | |
0

Assuming your web.config has the rewrite rules and is correct. It could be because URL Rewrite module isn't installed correctly and not registering the required dlls. Maybe try and reinstall the URL Rewrite module.

Here is the link for reference if reinstalling the URL Rewrite module didnt work: https://stackoverflow.com/a/25169995

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.