RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule ^wp\-content\/uploads\/?(.*)$ "http\:\/\/subdomain\.yourdomain\.com\/$1" [R=301,L]
Any way I can implement this on Cloudflare?
Thanks!
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$
RewriteRule ^wp\-content\/uploads\/?(.*)$ "http\:\/\/subdomain\.yourdomain\.com\/$1" [R=301,L]
Any way I can implement this on Cloudflare?
Thanks!
Page rules
Can I do this only for images? I want to host my images on media.site.com, but not redirect everyone there.
Thanks!
Match:
*yourdomain/wp-content/uploads/*
Redirect to:
https://subdomain.yourdomain/$2
Yes, you can, you simply need to place the right pattern as your URL match.
Thank you!
Actually, since the source is making use of two wildcards *
, the target should end with $2 instead of $1.
Thanks. Fixed.
Would you recommend doing this server side or via Cloudflare?
I am using that guide and it’s only temporary to prevent loss of search engine image traffic.
Thank you!
If you plan to use exclusively Cloudflare it is probably performance-wise a tad better to do it on Cloudflare straight away.
Do it at both server side and Cloudflare so if you are using CF, request doesn’t reach your server and if you some day remove CF, your website will not break.
Okay, thank you! I doubt I’d remove Cloudflare as i am now using it as an image cdn.
Plus in a few weeks I’ll probably remove the redirect after google reindexes.
This topic was automatically closed after 30 days. New replies are no longer allowed.