Forum Moderators: phranque

Message Too Old, No Replies

"QSA" directive not doing its job

Not passing arguments

         

craig1972

4:36 pm on Jul 23, 2009 (gmt 0)

10+ Year Member



Hi

I have an httpd.conf instruction like this:


RewriteRule ^/(.*)$ /index.php?do=$1 [L,QSA]

Which means that if I request this URL:


http://mydomain.com/sing

It actually becomes this:


http://mydomain.com/index.php?do=sing

But the whole point of having QSA directive is that everything should be passed as-is, including some param/value pairs. So if I request this URL:


http://mydomain.com/sing?time=now

It should direct to this:


http://mydomain.com/index.php?do=sing?time=now

But this is not what my program index.php is getting. It's only getting the part up to "sing". No time=now bit.

What am I missing?

craig1972

5:26 am on Jul 24, 2009 (gmt 0)

10+ Year Member



No thoughts about this at all?

jdMorgan

1:04 pm on Jul 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> No thoughts about this at all?

No, only dreams -- Pardon, but some of us are asleep at this time. This is not instant messaging.

If this code is in httpd.conf, then it should work as you expect. In .htaccess, you'd need a RewriteCond to prevent "index.php" from being rewritten to itself.

Typically, such "it doesn't work" problems are caused by:

1) Another rewriterule that rewrites the output of this one unexpectedly.
2) MultiViews (content negotiation) enabled, though not needed. (See Options directive)
3) AcceptPathInfo enabled when not needed. (Apache 2.x and later, see AcceptPathInfo directive)
4) Less frequently, mod_alias or mod_proxy directives matching RewriteRule output URL.

Have a look around at your other config settings -- Something is interfering with this rule.

Jim

craig1972

6:41 pm on Jul 24, 2009 (gmt 0)

10+ Year Member



Thanks JD.

(1) But I have no other RewriteRule that passes values to "index.php?do=". And the values of the first argument are actually coming in correctly. It's only the other arguments that don't get sent.

(2) I have


Options -Indexes +FollowSymLinks +ExecCGI -MultiViews

(3) I don't have that AcceptPathInfo directive anywhere. I use Apache 2.2.11.

(4) We don't use any Alias or Proxy stuff. Not in this domain's VirtualHost for sure.

Is there anything else we can check up? Btw, this is the last RewriteRule. The fact that the URL replacement is coming to this one means that there's no other conflicting RewriteRule, right?

This is all in the httpd.conf (although I do have a .htaccess, the Allowoverride None suppresses it...it's only for emergency backup).

Much appreciate any pointers, when you wake up :)

jdMorgan

7:34 pm on Jul 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only other thing I see that might be affecting this is that this statement is incorrect:
So if I request this URL:
http://example.com/sing?time=now
It should direct to this:
http://example.com/index.php?do=sing?time=now

As a result, perhaps your script is not parsing the query correctly. Correcting some terminology and describing Apache's actual behavior (in compliance with HTTP standards), the correct description is:
So if I request this URL:
http://example.com/sing?time=now
it should be rewritten to this filepath with query:
<DocumentRoot>/index.php?do=sing&time=now

Other than that, the problem is likely on my list above if this example reflects your actual code.

Jim

craig1972

2:52 am on Jul 25, 2009 (gmt 0)

10+ Year Member




So if I request this URL:
http://example.com/sing?time=now
it should be rewritten to this filepath with query:
<DocumentRoot>/index.php?do=sing&time=now

Are you suggesting that I use the words "DocumentRoot" in the httpd.conf? And how do I specify the "&" sign at the end in the RewriteRule?

jdMorgan

3:05 am on Jul 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you can neither affect nor prevent the server from using <DocumentRoot>. That is the very definition of your filespace on this server.

And you don't specify the ampersand; That is how Apache concatenates query parameters, because it's the standard.

But if your query string parser in your script is looking for two question marks, it's never going to find a second one, because that's where the ampersand will be.

Jim

craig1972

3:09 am on Jul 25, 2009 (gmt 0)

10+ Year Member



Oh, actually I found that the problem is on my index.php side -- I need to get the entire translated URL by using REQUEST_URI, not the "GET" value for "do".

Thanks so much, as always!