SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Capture Pretty URL?

    I am using a "Pretty URL", and would like to capture it, and store it in $_SESSION['returnToPage'], so that when I later call it, I will be taken back to the page I was on.

    How would I do that?

    Thanks,


    Debbie

  2. #2
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Here are a few "Pretty URL's" that I might want to capture...

    http://local.debbie/articles/rate-this-article/postage-meters-can-save-you-money

    http://local.debbie/articles/edit-comment/postage-meters-can-save-you-money/DoubleDee/2

    Thanks,


    Debbie

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you already tried $_SERVER['HTTP_REFERER'] ?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    You would use $_SERVER['REQUEST_URI'] to capture it and stuff it into a session before you move to the next page. Don't use HTTP_REFERER, it is not guaranteed to be available or not contaminated.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    You would use $_SERVER['REQUEST_URI'] to capture it and stuff it into a session before you move to the next page. Don't use HTTP_REFERER, it is not guaranteed to be available or not contaminated.
    Ok, some follow-up questions...

    1.) So, is $_SERVER['REQUEST_URI'] safe to use from a security standpoint?

    2.) Will $_SERVER['REQUEST_URI'] capture any "Pretty URL" scheme that I might have?

    3.) Is there any conflict between $_SERVER['REQUEST_URI'] and my "Pretty URLs" and the "Ugly URL" that my mod_rewrite is creating?

    Thanks,


    Debbie

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    1. Is REQUEST_URI safe...no (depends on you use it) but it is the only thing available, as it is what the server provides and uses itself.

    2. REQUEST_URI is whatever is used as the address the client uses within the HTTP request so yes.

    3. No conflict because the server (mod_rewrite) is using REQUEST_URI to match pretty URIs to their real URIs.

    Example HTTP request:
    Code:
    GET /fancy/pretty/URI/here/access/with/REQUEST/URI/on/server.html HTTP/1.1
    HOST: exmaple.com
    ...
    
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Wizard DoubleDee's Avatar
    Join Date
    Aug 2010
    Location
    Arizona
    Posts
    3,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    logic_earth,

    Okay, I think that answers my question. (Now if I can just figure out how to solve my Content-Architecture dilemma?!)

    Thanks!


    Debbie


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •