url rewrite - regular expression

S

sri_san

Hello group,
After going through a nice article at
MSDN(http://msdn2.microsoft.com/en-us/library/ms972974.aspx), I was
able to make the URL rewrite working except for coming up with a
generic rule using regular expressions.

Any URL with the format http://servername/dir/folder30/default.aspx
has to be converted to
http://servername/default.aspx?id=30

The one which I came up with and doesnt work is --

<Rules>
<RewriterRule>
<LookFor>~/dir/folder(\d)/default.aspx</LookFor>
<SendTo>~/default.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>

Could anyone point out what is wrong with the rule ?

Thanks,
Sam.
 
G

Gaurav Vaish \(MasterGaurav\)

What do you get?
Have you configured the module?
Also, I think you pattern "default.aspx" is somewhat wrong RegEx... it
should have been "default\.aspx"
(Recall that dot[.] means any character in regex :D)
 
S

sri_san

Thanks for pointing that out but it doesnt seem to work yet. I get a
404 ERROR -
"HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure
that it is spelled correctly. " which I take it as the rule/regular
expression is not working. When hardcoded, it works fine thought.

Thanks for your help!
Sam.



What do you get?
Have you configured the module?
Also, I think you pattern "default.aspx" is somewhat wrong RegEx... it
should have been "default\.aspx"
(Recall that dot[.] means any character in regex :D)


--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------


Hello group,
After going through a nice article at
MSDN(http://msdn2.microsoft.com/en-us/library/ms972974.aspx), I was
able to make the URL rewrite working except for coming up with a
generic rule using regular expressions.

Any URL with the format http://servername/dir/folder30/default.aspx
has to be converted to
http://servername/default.aspx?id=30

The one which I came up with and doesnt work is --

<Rules>
<RewriterRule>
<LookFor>~/dir/folder(\d)/default.aspx</LookFor>
<SendTo>~/default.aspx?id=$1</SendTo>
</RewriterRule>
</Rules>

Could anyone point out what is wrong with the rule ?

Thanks,
Sam.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top