URL Rewriting

If it is ASP.NET your using take a look at HTTP Handlers and HTTP Modules. They will be able to help you. I fyou can't find anything lte me know and I will post a sample.
 
Yeah, I read that article today and downloaded the source. It would 've been the ideal solution for what I need in fact. Though, it doesn't work. I let the web project reference to both "URLRewriter" and "ActionLessForm", and registered the tagprefix in the form, but accessing a page over localhost/domain/photography/1/2/45.aspx gives an error 404.

Is the structure of the web.config correct? Or did I do something very wrong? Do I need to change settings in IIS?

Code:
  <configSections><section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" /></configSections>
  <RewriterConfig>
    <Rules>
    <RewriterRule>
    	<LookFor>~/photography/(\d{2})/(\d{2})\.aspx</LookFor>
	<SendTo>~/photography/album/default.aspx?gid=$1&amp;aid=$2</SendTo>
    </RewriterRule>
    <RewriterRule>
      <LookFor>~/photography/(\d{2})/(\d{2})/(\d{2})\.aspx</LookFor>
      <SendTo>~/photography/photo/default.aspx?gid=$1&amp;aid=$2&amp;pid=$3</SendTo>
    </RewriterRule>
    </Rules>
  </RewriterConfig>
  <system.web>
    <httpHandlers>
      <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
    </httpHandlers>
   ...

Thanks in advance for everyone's help !

Regards,
Niels
 
I beleive /(d){2} will only match numbers 2 characters long. If you are trying to do /1/4/45 or similar it will not recognise it. you could try /(d)*
 
That should be (\d+) then, everything inside the parentheses to capture the entire number, and + to match at least 1 digit, and not also 0 which probably doesn't make sense.
 
OK, changed that d{2} to d+, however, i still have a 404 error.

web.config now loooks like this : I suppose there's something wrong in the item httpHandlers...

Code:
  <configSections>
      <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
  </configSections>
  <RewriterConfig>
    <Rules>
      <RewriterRule>
    	  <LookFor>http://localhost/ArsLuminis/photography/(\d+)/(\d+)\.aspx</LookFor>
               <SendTo>http://localhost/ArsLuminis/photography/album/default.aspx?gid=$1&amp;aid=$2</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>http://localhost/ArsLuminis/photography/(\d+)/(\d+)/(\d+)\.aspx</LookFor>
         <SendTo>http://localhost/ArsLuminis/photography/photo/default.aspx?gid=$1&amp;aid=$2&amp;pid=$3</SendTo>
      </RewriterRule>
    </Rules>
  </RewriterConfig>
  <system.web>
    <httpHandlers>
      <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
    </httpHandlers>
 
Back
Top