Forum Moderators: phranque
I am trying to get a rewrite rule to change a url such as:
http://www.example.com/foo/123/abc/456 to:
http://www.example.com/foo/foo.swf?domain=123&tile=abc&ord=456
I have a single rule (in an .htaccess in the /foo/ directory):
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ /foo/foo.swf?domain=$1&tile=$2&ord=$3 [L]
The rewrite log seems to be telling me that it's doing what I want
192.168.xx.xx - - [10/Oct/2007:11:59:37 --0700] [www.example.com/sid#91c6b48][rid#91e3090/initial] (2) [per-dir /var/www/html/foo/] rewrite123/abc/456 -> /foo/foo.swf?domain=123&tile=abc&ord=456
192.168.xx.xx - - [10/Oct/2007:11:59:37 --0700] [www.example.com/sid#91c6b48][rid#91e3090/initial] (3) split uri=/foo/foo.swf?domain=123&tile=abc&ord=456 -> uri=/foo/foo.swf, args=domain=123&tile=abc&ord=456
192.168.xx.xx - - [10/Oct/2007:11:59:37 --0700] [www.example.com/sid#91c6b48][rid#91e3090/initial] (1) [per-dir /var/www/html/foo/] internal redirect with /foo/foo.swf [INTERNAL REDIRECT]
However, it appears that the query string is not being appended to the redirect... I am not getting the correct output in the browser, in fact, it seems that it is just being rewritten to:
http://www.example.com/foo/foo.swf
Also, if i change the rule to redirect:
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ /foo/foo.swf?domain=$1&tile=$2&ord=$3 [L,R]
It does in fact work, and I am redirected to
http://www.example.com/foo/foo.swf?domain=123&tile=abc&ord=456
Does anyone know why the query string is not being added when it's a transparent rewrite?
[edited by: jdMorgan at 10:07 pm (utc) on Oct. 10, 2007]
[edit reason] example.com [/edit]
If the output of this rule needs to be proxied to a back-end server or passed through any other modules, be sure to use the [PT] flag on the rule. But before changing anything, and ignoring the browser address bar, is the correct content being served?
Jim
The exact same rule as a redirect *does* return the correct content (the same RewriteRule line but with [R] added).
There is no proxying involved (should there be?, and its not being passed to another module.
If I leave the RewriteRule to rewrite (not redirect) (no [R]), it returns just the foo.swf, as if i had just sent a request for [domain...]
Also, be sure that no other RewriteRule pattern will match the URL-path output by this rule; While the [L] flag stops mod_rewrite processing for this pass through the code, mod_rewrite in .htaccess behaves recursively, and will re-execute until it makes a pass where no further rewrites or redirects are invoked.
Jim
I just wrote a quick php script to see if I could duplicate the error, but PHP has no problem with the exact same rule.... so it's looking like the problem is with the swf...
I'm guessing maybe that rewrites (i.e. "Internal Redirect") somehow behave differently than a normal GET request, and that is throwing off the swf.