If I load an SWF with a query string at the end, like:
object.swf?this=that
… then “this” is properly recognized as a flashvar within the flash object.
But, if I set “this” via mod_rewrite, as in:
RewriteRule ^object$ lib/object.swf?this=that [QSA,NC,L]
… then “this” is undefined.
I even wrote a little PHP script to dump the contents of $_GET (changed the rewrite target temporarily), and I’m positive that the rewrite rule is working.
Any help greatly appreciated.
mod_rewrite clarification:
To demonstrate the strangeness of the problem, let me temporarily change the rewrite target to “object.php”, so the rule now reads:
RewriteRule ^object$ lib/object.php?this=that [QSA,NC,L]
I created object.php in the /lib/ directory with the following line:
<?php echo '<pre>'.print_r($_GET, true).'</pre>'; ?>
Then, when I navigate to /object, I get the following output:
Array
(
[this] => that
)
This demonstrates that the rewrite rule is working as expected.
Still, when I change the rewrite target back to the SWF, “this” is not recognized as a flashvar.
(I’d definitely check the rewrite log to make sure, but I don’t think I have access to it on the Media Temple server I’m using.)
I believe that it’s working exactly as it’s meant to. When you’re rewriting the URL, you’re performing the transformation on the server, and the process is entirely transparent to the client. While this isn’t a problem for your PHP script, which runs on the server, it is problematic for your Flash content, which runs on the client.
I suspect that the reason that adding a query string works is that the Flash player is able to parse out the relevant information from the request when it loads the movie object. However, when you use
mod_rewrite, the modified request is not available to the player, so it is not able to extract the information that you need.If you wanted to have the URL without the query string, it is possible to examine the request path of the loaded file inside of the SWF, so you could simply redirect to the Flash file without a query string on the server, and then inside of the SWF parse out the information that you’re currently getting with
mod_rewriteto determine what content to load internally. I’d have to brush up on my ActionScript to give you a code sample, but if you’re interested I’ll see what I can do.