SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    317
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Storing the non-.htaccess rewritten URL using PHP?

    I'm trying to write an SQL script to track traffic stats using PHP. But if someone accesses a page whose address has been rewritten using .htaccess, I'm not sure how to un-rewrite it.

    For instance, say that www.example.com/Content/SomeArticle rewrites to www.example.com/index.php?option=1. I want to insert the string "Content/SomeArticle" into the database, not "index.php?option=1". The predefined variables that I am aware of--such as PHP_SELF, PATH_TRANSLATED, REQUEST_URI--give the file with arguments, rather than the typed in/linked to URL.

    How can I store the "faux" URL using PHP?

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    phpinfo() is your best friend. Just insert it in your script and you'll see which env variable holds what you want.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    317
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stereofrog
    phpinfo() is your best friend. Just insert it in your script and you'll see which env variable holds what you want.
    Thanks. I was using phpinfo() but it didn't occur to me to control+F for the redirected URL.

    In case anyone's interest, the environment variables are REDIRECT_URL and REDIRECT_QUERY_STRING. Though first you have to check REDIRECT_STATUS; it there's a redirect, that will be 200 (I tried searching for other status codes for this variable, but couldn't find any). If there's no redirect the usual REQUEST_URI will do.


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
  •