"New" word is not working in ISAPI rewrite rule

Topics: Developer Forum, Project Management Forum, User Forum
Apr 30, 2009 at 7:33 AM
Hi friends,

I;ve creted the ISAPI rewriterule for asp.net website as explained below, Any help would be appriciated....

RewriteRule ^/abcd/[^(admin)](.*)/(.*)\.aspx(.*)  /abcd/template/$2.aspx$3 [L,I]

eg. www.abcd.com/test/test1.aspx?p=tttt    -->  www.abcd.com/template/test1.aspx?p=ttt

but when i use new keyword then rule not fired

eg.  www.abcd.com/new/test1.aspx?p=tttt   


Coordinator
May 1, 2009 at 8:12 AM

What do you intend by [^(admin)] ?

I don't know what that is - but if what you mean to say is "any word that is not "admin", then you have got it wrong.    the construct where you have square brackets, and inside the brackets a caret is the first character, allows you to specify a range of characters that do not match.  [^0-9] implies "not a numeric digit".  [^A-Z] implies not an uppercase character.   [^admin] would imply, any single character that is neither a, nor d, nor m, nor i, nor n.   It does not match "anything but 'admin'".  It matches a single char.  And I honestly don't know what [^(admin)] would do.  I do not believe it matches "any word  but 'admin'".

For that you need a negative lookahead.  Maybe something like (?!admin). 

Maybe try something like this:

RewriteRule ^/abcd/(?!admin)([^/]+)/([^/]+)\.aspx(.*)  /abcd/template/$2.aspx$3 [L,I]

In the above, [^/]+ matches any series of characters that does not include a slash. The + implies one or more characters, which I prefer in place of *, which implies zero or more characters.

I suggest you use the testdriver and test out the various expressions yourself. 

May 1, 2009 at 8:43 AM
Hi Cheeso,

Thank you very much for replying, actually the rule which i was using is wrong, got the help from your post and it is working fine for me.

One more time thank you very much