Demuri Celidze Demuri Celidze - 6 months ago 25
Apache Configuration Question

How to rewrite paths for certain file types with .htaccess?

I move my static files to CDN. There are images, fonts, js, css, and some of them include paths to other files. E.g. file
will be at
, and it contain path like
How to rewrite all those paths with .htaccess?


The following code should work:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
RewriteCond %{REQUEST_URI} \.(jpe?g|png|svg|css|js|eot|ttf|woff2?)$ [NC]
RewriteRule ^{REQUEST_URI} [R=301,L]

Keep adding other file extensions to the 2nd RewriteCond directive above.