URL rewrite help

Topics: Developer Forum, User Forum
Jul 25, 2011 at 7:58 AM

Hi,

 

I have 2 urls

1. http://<website>/features/articlehome.aspx

2. http://<website>/features/article.aspx?id=11&name=abcd


I want the urls to look like
1. http://<website>/features

2. http://<website>/features/11/abcd


Rules I wrote
RewriteRule ^/features /features/articlehome.aspx

RewriteRule ^/features/(\d+)/(.*) /features/article.aspx?id=$1&name=$2


The first rule is working. The second rule is also redirecting to the articlehome.aspx instead of article.aspx

What could be the error in rewrite rule?

Coordinator
Aug 3, 2011 at 12:13 AM

The rules are evaluated in order.

Your first rule matches both kinds of URLs.

If you swap the order of the rules in the ini file, you may get better results.

Good luck.

Aug 16, 2011 at 7:20 AM
Edited Aug 16, 2011 at 9:11 AM

Thanks for your reply. It helped a lot :)

Need another help.

If I want to sort a list of articles with the re-written url, what is the best method? How can I append a querystring to a re-written URL.

http://<website>/features?sort=asc

is not working ..

after reading the help, I applied

 

RewriteRule ^/features($|\?) /article/articlemain.aspx [QSA]

But it is throwing some exception.

The log says

Tue Aug 16 14:38:29 -  2884 - ParseRuleModifierFlags: '[QSA]'

Tue Aug 16 14:38:29 -  2884 - ParseRuleModifierFlags: token 'QSA'

Tue Aug 16 14:38:29 -  2884 - WARNING: unsupported modifier flag 'QSA' on RewriteRule

Tue Aug 16 14:38:29 -  2884 - ReadConfig: ERROR: line 29: invalid modifiers, Ignoring that rule.

Coordinator
Aug 17, 2011 at 1:57 PM
Edited Aug 17, 2011 at 1:58 PM

What version of IIRF do you have?  QSA has been supported since.... IIRF v1.2.16, which I released in July 2009.  See http://iirf.codeplex.com/workitem/19486

If you are using a v1.2.x.x version of IIRF you need to upgrade to the latest stable version. 

If you are using a v2.x version of IIRF, you need to show your IIRF.ini file in its entirety. 

Aug 18, 2011 at 5:11 AM

Thanks for your reply.

I was using IIRF v1.2.15. Tried the v2.x version, which is not getting installed in our test environment (Windows XP).

Replaced it with v1.2.16 and it is now working smoothly.

Thanks a lot for your help.