treehouse : what would you like to learn today?
Web Design Web Development iOS Development

What's a usefull replacement for the / character?

  • Hey,

    I'm using codeigniter for a new web app I'm making and I would like to pass URL's as a variable through the URL to the script.

    The way codeigniter works is:

    http://domain.com/class/function/variable1/variable2/etc...


    I want to be able to do something like this

    http://domain.com/class/function/http://www.google.com//variable2/etc...


    But I need to replace the /'s for obvious reasons. Any suggestions of a neutral character that isn't used in normal URLs? Currently I encode the url in base64 then decode it in the script but that takes too long.

    Cheers
  • There's 2 ways:

    * Method 1: Change the normal slashes in the "real" url:
    - Use parameters (http://domain.com/?foo=bar&this=that&ur ... m/&bli=bla )

    - User |-char and rewrite (.htaccess) to parameters
    http://domain.com/bar|that|http://www.goole.com/|bla

    - Use something else (be creative)

    * Method 2: Change the included URL:
    - User urlescape(); or rawurlescape(); (available in both PHP and javascript, both encode and decode)
    making the url like this:
    http://domain.com/variable/bla/http%3a% ... /variable2