iframe 的 mod_rewrite 指向 mediaurl &保留 GET 参数
我有一个 iframe 来嵌入音频,它指向这样的 src...
http://domain.com/embed/mediaID
在嵌入级别,我有一个 index.php
监听 GET 请求,但它当然永远不会收到请求,除非我这样做我的 .htaccess 中的某种重定向就像这样...
RewriteEngine On
RewriteRule ^([^/]*)$ index.php?var1=$1 [L]
这说明了路径模式,因此我可以指向这样的 mediaID
但这是不可扩展的,因为我无法轻松添加更多 GET 参数。
我看到 YouTube & Vimeo 指向 mediaID,但随后也允许 GET 参数。
我的理解是重写是解决这个问题的方法,但也许我错了。我绝对宁愿将 mediaID 作为 GET 参数传递,并跳过编写我将在 .htaccess 中使用的每个参数,但这不是 YouTube & 的方式。 Vimeo 已经走了,他们似乎找到了一种可扩展的方式来做到这一点。
为什么他们指向 mediaID 的方法比以 GET 方式传递 url 更好?我认为他们的方法是很好的做法,也许我假设太多了。
完成与媒体 ID 的直接链接并以可扩展的方式保留 GET 参数的最佳方法是什么。
I have an iframe to embed audio which points to a src like this...
http://domain.com/embed/mediaID
At the embed level I have an index.php
listening to GET requests but it will of course never get the requests unless I do some sort of redirect in my .htaccess like so...
RewriteEngine On
RewriteRule ^([^/]*)$ index.php?var1=$1 [L]
That accounts for the path schema so I can point to a mediaID
like that but this is unscalable in that I can't easily add more GET params.
I'm seeing that YouTube & Vimeo point to a mediaID but then also allow GET params thereafter.
My understanding is that a rewrite is the way to go for this but perhaps I'm mistaken. I definitely would rather pass the mediaID as a GET param and skip writing each param I'll ever use in the .htaccess but that is not the way YouTube & Vimeo have gone, they seem to have found a scalable way to do it.
Why is their approach of pointing to the mediaID better than passing the url as a GET? I take it their approach is good practice, perhaps I'm assuming to much.
What is the best way to accomplish a direct link to a media ID and retain the GET params in a scalable way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想在重写后保留现有的查询字符串,只需使用 < code>QSA flag 在您的规则上:
然后,除了
var1
之外,您还将收到作为原始请求的一部分传入的任何参数。If you want to retain the existing query string after your rewrite, just use the
QSA
flag on your rule:Then, in addition to
var1
, you'll receive whichever parameters were passed in as part of the original request.