1

我希望将特定文件夹中的特定扩展名 (mp3) 重定向/重写到使用 CDN 的子域。

为了让事情更清楚,只有当有人尝试像

http://www.example.com/compositions/interception.mp3

http://sub.example.com/interception.mp3 (subdomain on push zone CDN)
4

1 回答 1

0

用于RewriteCond匹配主机名www.example.com,匹配时执行目录中 mp3 的重写compositions/

RewriteEngine On

# If the domain matches www.example.com
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]

# Rewrite mp3's from composition/ to the CDN, capture filename in $1
# Performs a 301 redirect
RewriteRule ^compositions/(.*)\.mp3$ http://sub.example.com/$1.mp3 [L,R=301]
于 2012-11-07T04:41:22.943 回答