如果通过 mod_rewrite 设置,Flash 对象将无法识别查询字符串

发布于 2024-09-19 06:26:19 字数 948 浏览 3 评论 0原文

如果我加载末尾带有查询字符串的 SWF,例如:

object.swf?this=that

... 那么“this”将被正确识别为 flash 对象中的 flashvar。

但是,如果我通过 mod_rewrite 设置“this”,如下所示:

RewriteRule ^object$ lib/object.swf?this=that [QSA,NC,L]

...则“this”未定义。

我什至编写了一个小的 PHP 脚本来转储 $_GET 的内容(暂时更改了重写目标),并且我确信重写规则正在起作用。

非常感谢任何帮助。

mod_rewrite 说明:

为了演示问题的奇怪之处,让我暂时将重写目标更改为“object.php”,因此规则现在为:

RewriteRule ^object$ lib/object.php?this=that [QSA,NC,L]

我创建了 object.php/lib/ 目录中使用以下行:

<?php echo '<pre>'.print_r($_GET, true).'</pre>'; ?>

然后,当我导航到 /object 时,我得到以下输出:

Array
(
    [this] => that
)

这表明重写规则正在按预期工作。

不过,当我将重写目标更改回 SWF 时,“this”未被识别为 flashvar。

(我肯定会检查重写日志以确保,但我认为我无法在我正在使用的 Media Temple 服务器上访问它。)

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.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

掌心的温暖 2024-09-26 06:26:19

我相信它的工作原理完全符合预期。当您重写 URL 时,您是在服务器上执行转换,并且该过程对客户端来说是完全透明的。虽然这对于在服务器上运行的 PHP 脚本来说不是问题,但对于在客户端上运行的 Flash 内容来说却是个问题。

我怀疑添加查询字符串有效的原因是 Flash 播放器在加载影片对象时能够从请求中解析出相关信息。但是,当您使用 mod_rewrite 时,修改后的请求对播放器不可用,因此无法提取您需要的信息。

如果您想要不带查询字符串的 URL,可以检查 SWF 内部加载文件的请求路径,因此您可以简单地重定向到服务器上不带查询字符串的 Flash 文件,然后在SWF 解析出您当前使用 mod_rewrite 获取的信息,以确定要在内部加载的内容。我必须温习我的 ActionScript 才能为您提供代码示例,但如果您感兴趣,我会看看我能做什么。

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_rewrite to 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.

丶视觉 2024-09-26 06:26:19

让我们分解一下来找出问题所在。

检查重写日志 RewriteLog "/usr/local/var/apache/logs/rewrite.log" 以查看重写规则正在执行的操作。

查看 URL 重写指南: http://httpd.apache.org /docs/1.3/misc/rewriteguide.html 以确保您的规则中没有遗漏任何内容。

看来你的重写规则正在改变一些东西。我会测试不同的重写规则,直到失败为止:

示例:
规则 1:www.mysite.com 至 www.mysite.com/flash
规则 2:www.mysite.com/flash 至 www.mysite.com/myswf.swf
等等...

重点是找出它是否可以在某些情况下与 mod 重写一起使用,而在其他情况下则不能使用或根本不使用。

Lets break this down to find the problem.

Check your rewrite log RewriteLog "/usr/local/var/apache/logs/rewrite.log" to see what the rewrite rule is doing.

Take a look at the URL Rewriting guide: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html to make sure nothing is missing from your rule.

It seems that your rewrite rule is changing something. I would test different rewrite rules as such until I got a failure:

Example:
Rule 1: www.mysite.com to www.mysite.com/flash
Rule 2: www.mysite.com/flash to www.mysite.com/myswf.swf
etc...

The point is to find out if it will work with mod rewrite under some circumstance and not others or not at all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文