LoginSignup
2
2

More than 5 years have passed since last update.

Apacheのmod_sedを使用して画像パスをCloudFrontのURLに自動で切り替える方法

Posted at

Apacheの設定

下記、最短マッチに対応

<Directory /var/www/public>

  <IfModule sed_module>
      AddOutputFilter Sed html php
      OutputSed "s/\"\/\([^\"]*png\)\"/\"http\:\/\/test\.cloudfront\.net\/\1\"/g"
      OutputSed "s/\"\/\([^\"]*jpg\)\"/\"http\:\/\/test\.cloudfront\.net\/\1\"/g"
      OutputSed "s/\"\/\([^\"]*jpeg\)\"/\"http\:\/\/test\.cloudfront\.net\/\1\"/g"
      OutputSed "s/\"\/\([^\"]*gif\)\"/\"http\:\/\/test\.cloudfront\.net\/\1\"/g"
  </IfModule>
</Directory>
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2