clean urls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • somaboy mx

    clean urls

    I'm looking for a way to come up with clean urls like
    http://www.mysite.com/products/233 instead of
    http://www.mysite.com/products.php?pid=233 without having to rely on
    mod_rewrite or other server-specific solutions.

    any suggestions, links to articles etc?

    thanks.

    ..soma


  • Alvaro G Vicario

    #2
    Re: clean urls

    *** somaboy mx wrote/escribió (Fri, 1 Jul 2005 11:08:55 +0200):[color=blue]
    > I'm looking for a way to come up with clean urls like
    > http://www.mysite.com/products/233 instead of
    > http://www.mysite.com/products.php?pid=233 without having to rely on
    > mod_rewrite or other server-specific solutions.
    >
    > any suggestions, links to articles etc?[/color]

    If you don't want your webserver to parse your URLs, then you must have
    real files and directories (or at least symlinks, but of course these are
    quite server-specific too).

    A way to do so would be creating static files from a PHP script every time
    your database contents are modified.


    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • Daniel Tryba

      #3
      Re: clean urls

      somaboy mx <nosuch@fakemai l.fk> wrote:[color=blue]
      > I'm looking for a way to come up with clean urls like
      > http://www.mysite.com/products/233 instead of
      > http://www.mysite.com/products.php?pid=233 without having to rely on
      > mod_rewrite or other server-specific solutions.[/color]

      You could be lucky and have the first URL working (if the second one
      already works (depending on httpd configuration (Apache Multiview
      IIRC))) and find 233 in _SERVER['PATH_INFO']. But that still depends on
      platform. Alternatively you could build an intelligent 404 handler which
      should work on all platforms supporting dynamic 404 handlers (which I
      guess is most), but again platform dependend.

      Most likely to work out of the box is http://www.mysite.com/products.php/233.

      But I guess there is no single guaranteed multiplatform solution.

      Comment

      • Malcolm Dew-Jones

        #4
        Re: clean urls

        somaboy mx (nosuch@fakemai l.fk) wrote:
        : I'm looking for a way to come up with clean urls like
        : http://www.mysite.com/products/233 instead of
        : http://www.mysite.com/products.php?pid=233 without having to rely on
        : mod_rewrite or other server-specific solutions.

        : any suggestions, links to articles etc?

        If this is apache then it works, you don't need to do anything, except get
        the "products" to be known as a script.

        The "unused" parts of the path will then be given to you by the
        environment variable PATH_INFO

        If you use the name "products.p hp" then it should work as-is.



        (PATH_INFO will contain "/more/stuff/goes/here")

        If you really want to use "products" then you need to set something up so
        force apache to recognize the script as being a php script. Normally
        apache is configured to look for the ending ".php", but you can flag a
        specific files for special handling, or an entire directory, by putting
        the right rule in the conf file, or in the .htaccess file, though I
        haven't done that for this task so I can't show you an example.


        --

        This space not for rent.

        Comment

        Working...