Reputation: 4621
I am using urlrewriter.net
my intended url is like /articles/3/name_of_article/articles.aspx
& actual is articles.aspx?article =3;
(3 is just taken, it can be any number)
i am using regex like this
<rewriter>
<rewrite url="^/articles/(.+)/(.+)" to="/articles.aspx?article=$1" />
</rewriter>
it does not work, also if i delete module dll from references then also no exception is thrown.
1) how can ensure that module is loaded (via code)?
2) is my regex correct?
my web.config contains this:
<configSections>
<section name="rewriter" requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler,
Intelligencia.UrlRewriter" />
</configSections>
&
<httpModules>
<add type="Intelligencia.UrlRewriter.RewriterHttpModule,
Intelligencia.UrlRewriter" name="UrlRewriter" />
<add name="ScriptModule"
type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
Upvotes: 0
Views: 110
Reputation: 8234
This doesn't answer your question at all, but thought you might like to know. I had used both UrlRewriter and ISAPI_Rewrite, and ISAPI_Rewrite was much better in my opinion.
You don't have to include any references or rewrite rules in your web.config. Rather you install it as an ISAPI extension in IIS and it has it's own config file, and the rules you write are almost identical to the Apache mod_rewrite module, so if you are familiar with that module it is another advantage.
Also, since it is executed at the web server level before being passed to the .NET framework, it doesn't need to be tied into the ASP.NET request life cycle.
You can check it out here. ISAPI_Rewrite 3
Upvotes: 0
Reputation: 132862
2) is my regex correct?
No, you should probably change it to ^/articles/([^/]+)/.+$
, otherwise the first capture will gobble up "3/name_of_article" and not just "3", and you don't need the second capture group. You can also write it with a non-greedy match in the capture group, e.g. ^/articles/(.+?)/.+$
.
Upvotes: 1