CDN Related: Automatic Override Image URL from .htaccess

Recently I bought a CDN and set it up. On my website, images are stored in a folder named “images”, and the image URLs are obviously linked in this way . (*For example: images / some_image.png *)

Since I want to use the CDN correctly, I need to rewrite the URL without manually changing the path of each image.

I tried a .htaccess code and it is recommended for similar problems

RewriteEngine On
RewriteBase /
RewriteRule ^images/(.*)$ http://cdn.mydomain.com/$1 [L,R=301]

But this does not seem to be normal, because all images are incorrect.

So I Want to know the changes in this code. Any response would be greatly appreciated.

This should work:

RewriteCond %{HTTP_HOST} ^yourdomain\.com$[OR]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule ^images\/?(.*)$"http\:\/\/cdn\.yourdomain\.com\/$1" [R=301,L]

But please note that this Just a temporary solution! In order to make the most of your CDN, you need to manually point images to the CDN to save an HTTP for each image.

I recently bought a CDN and performed Settings. In my website, images are stored in a folder named “images”, and the image URLs are obviously linked in this way. (*Example: images / some_image.png *)

< p>Since I want to use the CDN correctly, I need to rewrite the URL without manually changing each image path.

I tried a .htaccess code, which is recommended for similar problems

< p>

RewriteEngine On
RewriteBase /
RewriteRule ^images/(.*)$http://cdn.mydomain.com/$1 [L,R=301]

But this doesn't seem to be normal, because all images are incorrect.

So I want to know the changes in this code. Any response would be greatly appreciated.

p>

This should work:

RewriteCond %{HTTP_HOST} ^yourdomain\.com$[OR]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule ^images\/?(.*)$"http\:\/\/cdn\.yourdomain\.com\/$1" [ R=301,L]

But please note that this is only a temporary solution! In order to make the most of your CDN, you need to manually point images to the CDN to save an HTTP for each image.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1302 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.