.htaccess重写问题

发布于 2024-10-04 02:13:29 字数 653 浏览 0 评论 0原文

我想要它,以便目录中的任何 swf 媒体都被重定向到一个文件,例如

http://website.com/swf.php?d=file

然后抛出 http 访问,将上面的链接更改为

http://website.com/file

文件

http://website.com/thisvideo.swf

所以让我们假设我有我希望它重定向到的 http://website.com/swf.php?d=thisvideo.swf

但是使用 .htaccess 将上面的链接更改为 http://website.com/thisvideo.swf

因此,当他们访问 thisvideo.swf 时,它不会转到直接 swf 但包含查询的 php 文件(假设通过 .htaccess 隐藏)。

我希望你明白我想说的,但我不知道如何做第一步重定向(如果是 swf)或重写。

I want it so that any swf media in a directory gets redirected to a file like

http://website.com/swf.php?d=file

Then threw http access, change the link above to

http://website.com/file

so lets assume I have the file

http://website.com/thisvideo.swf

I want it to redirect to
http://website.com/swf.php?d=thisvideo.swf

BUT with .htaccess change the above link to
http://website.com/thisvideo.swf

So when they visit thisvideo.swf it doesnt go to the direct swf but the php file with the query in it (assuming thats hidden via the .htaccess).

I hope you get what im trying to say, but I don't know how to do the first step of redirecting if its swf, or rewriting.

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

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

发布评论

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

评论(2

挽梦忆笙歌 2024-10-11 02:13:29

应该很简单:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.swf$
RewriteRule ^(.*)$ /virtual/path/to/script.php?d=$1 [NC,L]

这基本上是说“获取带有 .swf 扩展名的任何 URL,保持其 URL 相同(屏蔽它),并将请求转发到 script.php

编辑:如果您想严格控制它,您可以在 RewriteEngine On: 下面添加以下内容,

RewriteCond ${REQUEST_FILENAME} -f

这将强制它仅重写有效文件(例如,您不会重定向任何 404)。

Should be simple:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.swf$
RewriteRule ^(.*)$ /virtual/path/to/script.php?d=$1 [NC,L]

This basically says "take any URL with a .swf extension, keep its URL the same (mask it), and forward the request to script.php.

Edit: if you want to be strict about it, you could add the following immediately below RewriteEngine On:

RewriteCond ${REQUEST_FILENAME} -f

which will force it only to rewrite valid files (eg, you wouldn't be redirecting any 404's).

决绝 2024-10-11 02:13:29
RewriteEngine On
RewriteRule ^(.*\.swf)$ /swf.php?d=$1 [QSA,L]
RewriteEngine On
RewriteRule ^(.*\.swf)$ /swf.php?d=$1 [QSA,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文