By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

REQUEST_URI

P: n/a
At some point, $_SERVER["REQUEST_URI"] 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=value"
$_SERVER["REQUEST_URI"] should be "/path/script"

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

Is this supposed to happen? Is there a configuration that controls this?
Thanks,
Jeremy
Dec 6 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jeremy:
Example: for URL "http://www.foo.bar/path/script?thing=value"
$_SERVER["REQUEST_URI"] should be "/path/script"

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

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.

http://skrb.org/ietf/http_errata.html#uriquery

--
Jock

Dec 7 '06 #2

P: n/a
John Dunlop wrote:
Jeremy:
>Example: for URL "http://www.foo.bar/path/script?thing=value"
$_SERVER["REQUEST_URI"] should be "/path/script"

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

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.

http://skrb.org/ietf/http_errata.html#uriquery
I actually *don't want* the query string to be in there. In the past,
using $_SERVER["REQUEST_URI"] 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)?
Dec 7 '06 #3

P: n/a
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...@john.dunlop.namewrote:
Jeremy:
Example: for URL "http://www.foo.bar/path/script?thing=value"
$_SERVER["REQUEST_URI"] should be "/path/script"
But it's now "/path/script?thing=value".
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.

http://skrb.org/ietf/http_errata.html#uriquery

--
Jock
Dec 10 '06 #4

P: n/a
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="<?=$_SERVER['PHP_SELF']?>">
<input type="text" />
<button type="submit">Submit</button>
</form>
Whoops! The form now submits to /foobar-script.php instead of /foobar.

Jeremy
Dec 14 '06 #5

P: n/a
Jeremy:
I actually *don't want* the query string to be in there. In the past,
using $_SERVER["REQUEST_URI"] 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

Dec 14 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.