简体   繁体   中英

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. g18/g18_flashfile.swf but now i've moved them into 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. This just error 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. Does anyone know if swf are some kind of term used in mod_rewrite?

The regular expression

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

matches both g18/g18_flashfile.swf and assets/flash/g18_flashfile.swf . Since the L flag might not work as you expected , this is a problem.

Just change the regular expression so that it doesn't match your rewritten path:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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