in reply to mod rewrite on mod perl handler skip trans handler phase

What you have here is mostly a mod_rewrite question. Turn on the debugging log for mod_rewrite. It will show you what string is coming in for the URL. It's probably not what you think it is.

Also, there is no need to use mod_rewrite for this with what you've shown so far. You could just set your mod_perl handler to respond to "Location /" instead of rewriting.

  • Comment on Re: mod rewrite on mod perl handler skip trans handler phase

Replies are listed 'Best First'.
Re^2: mod rewrite on mod perl handler skip trans handler phase
by ducbot (Initiate) on Dec 19, 2006 at 20:17 UTC
    I currently have "Location /" mapped to a Index handler which shows the index page. I was thinking about a check like:
    if location isnt mapped in httpd.conf or location doesnt exist on file system redirect to profile
    So if someone entered $base_url/$f_id ie: myspace.com/perlmonks

    if the httpd.conf doesnt contain "Location /perlmonks" and the file structure doesnt contain the "perlmonks" directory/file redirect to the profile handler.

    but not sure how the performance might be. Do you guys think this is an efficient way of doing this?

    Checking the file on the file structure would require a stat for each request which can be expensive.

    Guess an easier option is to just set up a separate url for profiles. IE: profiles.myspace.com/$f_id

      Okay, I think i finally understand your problem. You want to only intercept requests that didn't map to anything else. I don't think you can do that in any easy way with mod_rewrite. It would certainly be much easier to use a top-level prefix (like your /u example) or a virtual host (like your profiles.myspace.com example).

      One relatively simple thing you can try is to just map your perl module to the handler for 404 NOT FOUND errors. Then it will only get things that didn't match anything else. That's the easiest route, if you don't want to use the naming tricks.