简体   繁体   English

Mod_rewrite SWF文件到另一个目录

[英]Mod_rewrite swf file to another directory

I am working on a client's site that used to have all .swf files in directories via product code eg. 我在一个客户站点上工作,该站点以前通过产品代码(例如)将所有.swf文件放在目录中。 g18/g18_flashfile.swf but now i've moved them into assets/flash/g18_flashfile.swf g18/g18_flashfile.swf但现在我将它们移至assets/flash/g18_flashfile.swf

I have tried to mod_rewrite the request to the new location due to external sites hotlinking to the file. 由于外部站点热链接到文件,我试图将请求mod_rewrite到新位置。 This just error 500s 这只是错误500s

RewriteRule ^([^/]+)/([^.]+)\.swf$ assets/flash/$1/$2\.swf [L]

I also cannot just do a redirect anything as I am already using the following 我也不能只是重定向任何东西,因为我已经在使用以下内容

RewriteRule ^(.*)/$ product.php?ref=$1 [L]

Any help would be great as I am scratching my head on this one. 任何帮助都将非常有用,因为我会为此抓狂。

EDIT 编辑

Whats even stranger is when I do 我什至陌生的是

RewriteRule ^([^/]+)/([^.]+)\.swf$ assets/flash/$1/$2\.html [L]

It works (obviously it 404s because there isn't a .html file) but the rewrite works. 它可以工作(显然它是404s,因为没有.html文件),但是重写可以工作。 Does anyone know if swf are some kind of term used in mod_rewrite? 有人知道swf是mod_rewrite中使用的某种术语吗?

The regular expression 正则表达式

^([^/]+)/([^.]+)\.swf$

matches both g18/g18_flashfile.swf and assets/flash/g18_flashfile.swf . 匹配g18/g18_flashfile.swfassets/flash/g18_flashfile.swf Since the L flag might not work as you expected , this is a problem. 由于L标志可能无法按预期工作 ,因此这是一个问题。

Just change the regular expression so that it doesn't match your rewritten path: 只需更改正则表达式,使其与您重写的路径不匹配:

RewriteRule ^([^/]+)/([^/.]+)\.swf$ assets/flash/$1/$2\.swf [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM