URL rewriting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricky Romaya

    URL rewriting

    Can I have somekind of URL rewriting mechanism without touching the web
    server's configuration (implemented in pure PHP) and win32 compatible? All
    the info I have teaches about apache's mod_rewrite or other methods which
    includes httpd.conf/htaccess editing. Assume I don't have any access to
    both files.
  • R. Rajesh Jeba Anbiah

    #2
    Re: URL rewriting

    Ricky Romaya wrote:[color=blue]
    > Can I have somekind of URL rewriting mechanism without touching the[/color]
    web[color=blue]
    > server's configuration (implemented in pure PHP) and win32[/color]
    compatible? All[color=blue]
    > the info I have teaches about apache's mod_rewrite or other methods[/color]
    which[color=blue]
    > includes httpd.conf/htaccess editing. Assume I don't have any access[/color]
    to[color=blue]
    > both files.[/color]

    Explain what you want to achieve, like "from" and "to" URLs?

    --
    <?php echo 'Just another PHP saint'; ?>
    Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

    Comment

    • Ricky Romaya

      #3
      Re: URL rewriting

      "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in
      news:1106756528 .100684.128870@ f14g2000cwb.goo glegroups.com:[color=blue]
      >
      > Explain what you want to achieve, like "from" and "to" URLs?
      >[/color]
      Well, at least the same basic functionality of Apache's mod_rewrite. For
      example, this URL:



      will be translated to



      before the webserver finally calls index.php with 'lang' and 'page'
      arguments.

      Comment

      • R. Rajesh Jeba Anbiah

        #4
        Re: URL rewriting

        Ricky Romaya wrote:[color=blue]
        > "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in
        > news:1106756528 .100684.128870@ f14g2000cwb.goo glegroups.com:[color=green]
        > >
        > > Explain what you want to achieve, like "from" and "to" URLs?
        > >[/color]
        > Well, at least the same basic functionality of Apache's mod_rewrite.[/color]
        For[color=blue]
        > example, this URL:
        >
        > http://www.foobar.com/en/my-index/
        >
        > will be translated to
        >
        > http://www.foobar.com/index.php?lang=en&page=my-index
        >
        > before the webserver finally calls index.php with 'lang' and 'page'
        > arguments.[/color]

        I don't think, this case will be possible then. But, will be happy
        if someone proves the other.

        --
        <?php echo 'Just another PHP saint'; ?>
        Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

        Comment

        • NC

          #5
          Re: URL rewriting

          Ricky Romaya wrote:[color=blue]
          >
          > Can I have somekind of URL rewriting mechanism without
          > touching the web server's configuration (implemented
          > in pure PHP) and win32 compatible?[/color]

          Not really... URL rewriting is a pretty low-level HTTP
          server functionality.. . This said, there may be ways
          to make your URLs shorter and prettier...
          [color=blue]
          > For example, this URL:
          >
          > http://www.foobar.com/en/my-index/
          >
          > will be translated to
          >
          > http://www.foobar.com/index.php?lang=en&page=my-index
          >
          > before the webserver finally calls index.php with
          > 'lang' and 'page' arguments.[/color]

          Again, URL rewriting is out of question, so what I am about
          to suggest is more like alternative ways of communicating
          values without communicating names.

          There is a hack (which I really don't recommend because I am
          not sure this Apache behavior is intended)... Call your home
          page like this:



          This should set your $_SERVER['PHP_SELF'] to "/en/my-index/",
          which you can then parse like this:

          $vars = explode('/', $_SERVER['PHP_SELF']);
          $lang = $vars[1];
          $page = $vars[2];

          There is another hack, more standards-friendly:



          This should set your $_SERVER['QUERY_STRING'] to "en/my-index/"
          which you can parse like this:

          $vars = explode('/', $_SERVER['QUERY_STRING']);
          $lang = $vars[0];
          $page = $vars[1];

          Cheers,
          NC

          Comment

          Working...