CDN图片网址
https://cdn{sid}.example.com/{f1}/image_{id}.{ext}
我将调用图像文件
<img src="image.php?cdn=42&f1=folder&id=1234&ext=jpg" alt="Hello" />
到目前为止我找到的.htaccess代码
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^image.php https://cdn42.example.com/folder/image_1234.jpg
如何将params(sid,f1,id等)填充到htaccess?提前谢谢......
答案 0 :(得分:1)
要从image.php?cdn=42&f1=folder&id=1234&ext=jpg
重定向到https://cdn{sid}.example.com/{f1}/image_{id}.{ext}
,以下规则应该有效。这假设您正在尝试从服务器重定向到CDN,而不是尝试重写CDN本身:
RewriteCond %{QUERY_STRING} ^cdn=([^&]*)&f1=([^&]*)&id=([^&]*)&ext=(.*)$
RewriteRule ^image.php$ https://cdn%1.example.com/%2/image_%3.%4