Loading ...
Sorry, an error occurred while loading the content.
 

mod_rewrite anyone?

Expand Messages
  • rlution
    Thanks to all for the responses on my REST questions. There were a number of reponses to my question on handling URI parsing and dispatching on the
    Message 1 of 2 , Dec 29, 2004
      Thanks to all for the responses on my REST questions.

      There were a number of reponses to my question on handling URI parsing
      and dispatching on the server-side. Some employ "one-big if-else
      statement", others a java servlet with an XML config file.

      Anyone exlusively using mod_rewrite to handle this?
    • Vincent D Murphy
      1. If you are parsing PATH_INFO, you can use mod_rewrite to de-uglify the cgi script path. /readable/foo/bar - /cgi-bin/ugly.cgi/foo/bar I don t have
      Message 2 of 2 , Dec 29, 2004
        1. If you are parsing PATH_INFO, you can use
        mod_rewrite to de-uglify the cgi script path.

        /readable/foo/bar -> /cgi-bin/ugly.cgi/foo/bar

        I don't have mod_rewrite code for this but its a
        trivial one-liner (after setup).

        2. Pick keys out of the URL with mod_rewrite and
        rewrite them as query-string arguments.

        From .htaccess:

        RewriteBase /readable
        RewriteRule ^invoices/$ cgi/invoices/index.pl.cgi
        RewriteRule ^invoices/([0-9]+)?$ invoices/$1/ [R=permanent]
        RewriteRule ^invoices/([0-9]+)/$ cgi/invoices/one.pl.cgi?id=$1
        RewriteRule ^invoices/([0-9]+)/form/$ cgi/invoices/form.pl.cgi?id=$1

        I would think this complicates use of the query-string
        for queries, but I didn't try that.

        On the other hand, this could work well for adapting
        existing scripts to expose non-dispatch-query-string
        URLs. Some do this to be more available to spiders
        like GoogleBot.

        PS: I publish all my URLs to have a leading slash so
        there I can have terse relative URLs
        (e.g. ./foo , ../foo/bar ) in HTML representations,
        and have legacy browsers interpret them consistently.
      Your message has been successfully submitted and would be delivered to recipients shortly.