sajjadlogic
16 Jun 2006, 08:01 AM
Hello
I am using URL rewriting through a downloaded .NET application. Which uses web.config file for rewriting rules and some other code. The snapshot of web.config is below. I have also checked some other applications which are using the same technique.
WEB.CONFIG FILE
=========================
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/monitors\.aspx</LookFor>
<SendTo>~/default.aspx?c=2</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/computers\.aspx</LookFor>
<SendTo>~/default.aspx?c=3</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/software-(\d{2})\.aspx</LookFor>
<SendTo>~/default.aspx?c=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>
=====================================================
The problem is, that it is dependent on web.config file which only executes when an ASPX request arrives on server. For example, if I rewrite a *.aspx URL in *.html or in any other file format, the web.config file is not activated by the server and hence I get a 404. For example, I cannot use this kind of rewrite rule in my web.config.
<RewriterRule>
<LookFor>~/software-(\d{2})\.html</LookFor>
<SendTo>~/default.aspx?c=$1</SendTo>
</RewriterRule>
Because server gets a request of *.html file and it doesn't hand over it to .NET engine, so finally web.config is not read for this request.
I want to ask for any other way of URL rewriting in asp.net in which I can use any file extension like *.html, *.php, etc in re-writing rules. Like I can do in Apache mod-rewrite.
Thanks.
I am using URL rewriting through a downloaded .NET application. Which uses web.config file for rewriting rules and some other code. The snapshot of web.config is below. I have also checked some other applications which are using the same technique.
WEB.CONFIG FILE
=========================
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/monitors\.aspx</LookFor>
<SendTo>~/default.aspx?c=2</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/computers\.aspx</LookFor>
<SendTo>~/default.aspx?c=3</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/software-(\d{2})\.aspx</LookFor>
<SendTo>~/default.aspx?c=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>
=====================================================
The problem is, that it is dependent on web.config file which only executes when an ASPX request arrives on server. For example, if I rewrite a *.aspx URL in *.html or in any other file format, the web.config file is not activated by the server and hence I get a 404. For example, I cannot use this kind of rewrite rule in my web.config.
<RewriterRule>
<LookFor>~/software-(\d{2})\.html</LookFor>
<SendTo>~/default.aspx?c=$1</SendTo>
</RewriterRule>
Because server gets a request of *.html file and it doesn't hand over it to .NET engine, so finally web.config is not read for this request.
I want to ask for any other way of URL rewriting in asp.net in which I can use any file extension like *.html, *.php, etc in re-writing rules. Like I can do in Apache mod-rewrite.
Thanks.