Forum Moderators: phranque
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?
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
(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 :)
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
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
Jim
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