REQUEST_URI

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

    REQUEST_URI

    At some point, $_SERVER["REQUEST_UR I"] started including the query
    string. It seems to me that it didn't do this before.

    Example: for URL "http://www.foo.bar/path/script?thing=va lue"
    $_SERVER["REQUEST_UR I"] should be "/path/script"

    But it's now "/path/script?thing=va lue".

    Is this supposed to happen? Is there a configuration that controls this?


    Thanks,
    Jeremy
  • John Dunlop

    #2
    Re: REQUEST_URI

    Jeremy:
    Example: for URL "http://www.foo.bar/path/script?thing=va lue"
    $_SERVER["REQUEST_UR I"] should be "/path/script"
    >
    But it's now "/path/script?thing=va lue".
    >
    Is this supposed to happen?
    An "abs_path" Request-URI can't contain a query part, strictly
    speaking, because the ABNF of RFC2616 doesn't allow it (RFC2616: 5.1.2;
    RFC3986: 3.5). The only way to pass data in the query part is to send
    an absolute URI.

    However, the errata mends this, so you can expect future revisions
    to allow query parts in relative Request-URIs. I shouldn't worry too
    much about it.

    Find official errata and updates for HTTP standards from the Internet Engineering Task Force (IETF). Stay informed with accurate information.


    --
    Jock

    Comment

    • Jeremy

      #3
      Re: REQUEST_URI

      John Dunlop wrote:
      Jeremy:
      >
      >Example: for URL "http://www.foo.bar/path/script?thing=va lue"
      >$_SERVER["REQUEST_UR I"] should be "/path/script"
      >>
      >But it's now "/path/script?thing=va lue".
      >>
      >Is this supposed to happen?
      >
      An "abs_path" Request-URI can't contain a query part, strictly
      speaking, because the ABNF of RFC2616 doesn't allow it (RFC2616: 5.1.2;
      RFC3986: 3.5). The only way to pass data in the query part is to send
      an absolute URI.
      >
      However, the errata mends this, so you can expect future revisions
      to allow query parts in relative Request-URIs. I shouldn't worry too
      much about it.
      >
      Find official errata and updates for HTTP standards from the Internet Engineering Task Force (IETF). Stay informed with accurate information.

      >
      I actually *don't want* the query string to be in there. In the past,
      using $_SERVER["REQUEST_UR I"] has been a reliable way to submit back to
      the current page when mod_rewrite is messing with the URL (meaning using
      the current script path won't work). Now, it's not really working that
      well because it's including the current query string and messing things up.

      Am I on crazy pills or did this not used to happen? Is this apache
      messing up or PHP messing up (or me messing up)?

      Comment

      • Curtis

        #4
        Re: REQUEST_URI

        Use $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME']. Neither of these
        include the query string.

        On Dec 7, 12:57 am, "John Dunlop" <usenet+2...@jo hn.dunlop.namew rote:
        Jeremy:
        >
        Example: for URL "http://www.foo.bar/path/script?thing=va lue"
        $_SERVER["REQUEST_UR I"] should be "/path/script"
        >
        But it's now "/path/script?thing=va lue".
        >
        Is this supposed to happen? An "abs_path" Request-URI can't contain a query part, strictly
        speaking, because the ABNF of RFC2616 doesn't allow it (RFC2616: 5.1.2;
        RFC3986: 3.5). The only way to pass data in the query part is to send
        an absolute URI.
        >
        However, the errata mends this, so you can expect future revisions
        to allow query parts in relative Request-URIs. I shouldn't worry too
        much about it.
        >
        Find official errata and updates for HTTP standards from the Internet Engineering Task Force (IETF). Stay informed with accurate information.

        >
        --
        Jock

        Comment

        • Jeremy

          #5
          Re: REQUEST_URI

          Curtis wrote:
          Use $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME']. Neither of these
          include the query string.
          >
          But neither of these will actually return the request URI; they will
          only return the filename and/or path of the script.

          Example:

          ..htaccess:
          -----------------------
          RewriteEngine On
          RewriteRule ^foobar$ /foobar-script.php


          foobar-script.php (accessed by URI /foobar)
          -----------------------
          <form action="<?=$_SE RVER['PHP_SELF']?>">
          <input type="text" />
          <button type="submit">S ubmit</button>
          </form>


          Whoops! The form now submits to /foobar-script.php instead of /foobar.

          Jeremy

          Comment

          • John Dunlop

            #6
            Re: REQUEST_URI

            Jeremy:
            I actually *don't want* the query string to be in there. In the past,
            using $_SERVER["REQUEST_UR I"] has been a reliable way to submit back to
            the current page when mod_rewrite is messing with the URL (meaning using
            the current script path won't work). Now, it's not really working that
            well because it's including the current query string and messing things up.
            Think twice about publishing two different URLs pointing to the
            same resource.

            You can separate the query part from the path part by looking for
            the first question mark.

            --
            Jock

            Comment

            Working...