我希望将特定文件夹中的特定扩展名 (mp3) 重定向/重写到使用 CDN 的子域。
为了让事情更清楚,只有当有人尝试像
http://www.example.com/compositions/interception.mp3
至
http://sub.example.com/interception.mp3 (subdomain on push zone CDN)
我希望将特定文件夹中的特定扩展名 (mp3) 重定向/重写到使用 CDN 的子域。
为了让事情更清楚,只有当有人尝试像
http://www.example.com/compositions/interception.mp3
至
http://sub.example.com/interception.mp3 (subdomain on push zone CDN)
用于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]