0
votes

I'm new to using the URL Rewrite module and I'm having trouble with what I thought would be a simple URL rewrite for forum threads (using IIS 7.5)

I need to rewrite:

/forum/100/2534/friendly-title

or:

/forum/100/2534/334/comment/friendly-thread-title

to:

/forum/?forum=100&thread=2534&post=334&postType=comment

The rule that I have written (not working) is:

^forum/([1-9][0-9][0-9]*)/([1-9]*)/(([1-9]*)/(post|comment)/)?([a-zA-Z0-9-]{5,50})$

Which maps to:

/forum/?forum={R:1}&thread={R:2}&post={R:4}&postType={R:5}

I'm getting a 404 error.

1
I tested the regex and it does all the values, though R:4 and R:5 are NULL when I try to map the first type of friendly URL. - Redtopia

1 Answers

1
votes

It's correct that {R:4} and {R:5} are empty when you use the first URL. That's because there are no values for these fields. The RegEx still matches though so the URL will still be rewritten. Your code should properly handle empty values for the post and postType querystring parameters to display the entire thread and not just a specific comment (at least that what I assume is suppose to happen).

By the way, a more logical URL structure would be:

/forum/100/2534/friendly-thread-title/comment/334

This won't help you this this particular problem though but just on a side note.