Title: Rewrite CNAME URLs to https://s3.amazonaws.com?
Last modified: October 2, 2017

---

# Rewrite CNAME URLs to https://s3.amazonaws.com?

 *  [JohnP](https://wordpress.org/support/users/johnp/)
 * (@johnp)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/rewrite-cname-urls-to-https-s3-amazonaws-com/)
 * I’ve been using this plugin successfully since the TanTan days. I didn’t want
   to have Amazon links in my HTML, so I set up a CNAME assets.example.com and pointed
   that at my S3 bucket.
 * Now I want to switch my site to https, and I’m trying to re-write the URLs so
   that
    [http://assets.example.com/wp-content/uploads/image.jpg](http://assets.example.com/wp-content/uploads/image.jpg)
   changes to: [https://s3.amazonaws.com/assets.example.com/wp-content/uploads/image.jpg](https://s3.amazonaws.com/assets.example.com/wp-content/uploads/image.jpg)
   which is the same file served securely.
 * I’ve tried putting the following in htaccess, just after RewriteEngine On
 * RewriteCond %{HTTP_HOST} ^assets.example.com$ [NC]
    RewriteRule ^(.*)$ [https://s3.amazonaws.com/assets.example.com/%](https://s3.amazonaws.com/assets.example.com/%){
   REQUEST_URI} [R=301,NC,L,QSA]
 * but it doesn’t work. Have I made a mistake or am I trying something impossible?
 * Sorry if this is seen as off-topic, but there must be many other users of this
   plugin in a similar situation to me.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [A5hleyRich](https://wordpress.org/support/users/a5hleyrich/)
 * (@a5hleyrich)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/rewrite-cname-urls-to-https-s3-amazonaws-com/#post-9547614)
 * The rewrite rule won’t work because your assets are using a CNAME which points
   directly to S3, so the .htaccess rules are never triggered because those requests
   don’t hit your server.
 * Unfortunately if you want to continue masking the S3 URL you will need to use
   a CDN, because S3 doesn’t support custom domains over HTTPS. It’s possible to
   use CloudFlare’s free CDN as detailed in this article:
 * [https://deliciousbrains.com/wp-offload-s3/doc/cloudflare-setup/](https://deliciousbrains.com/wp-offload-s3/doc/cloudflare-setup/)
 *  Thread Starter [JohnP](https://wordpress.org/support/users/johnp/)
 * (@johnp)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/rewrite-cname-urls-to-https-s3-amazonaws-com/#post-9547651)
 * I don’t care about masking the S3 URL, I just want the files served by https 
   so that users don’t receive mixed content warnings.
 * Thank you for your response A5hleyRich – I guess I will have to learn about Cloudflare
   or CloudFront after all – I was hoping there was an easier way.
    -  This reply was modified 8 years, 8 months ago by [JohnP](https://wordpress.org/support/users/johnp/).
 *  Plugin Contributor [A5hleyRich](https://wordpress.org/support/users/a5hleyrich/)
 * (@a5hleyrich)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/rewrite-cname-urls-to-https-s3-amazonaws-com/#post-9550918)
 * If you’re not concerned about masking the URL you can disable the ‘Custom domain’
   and enable ‘Force HTTPS` in WP Offload S3 and the links will update accordingly.
 * [https://deliciousbrains.com/wp-offload-s3/doc/settings/](https://deliciousbrains.com/wp-offload-s3/doc/settings/)
 *  Thread Starter [JohnP](https://wordpress.org/support/users/johnp/)
 * (@johnp)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/rewrite-cname-urls-to-https-s3-amazonaws-com/#post-9551063)
 * That’s great news, and it worked!
 * I’ve got the CNAME routed through Cloudflare but it’s not doing anything.
 * I was beginning to think I would have to edit the database, so your advice is
   very welcome.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Rewrite CNAME URLs to https://s3.amazonaws.com?’ is closed to new replies.

 * ![](https://ps.w.org/amazon-s3-and-cloudfront/assets/icon-256x256.jpg?rev=1809890)
 * [WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage](https://wordpress.org/plugins/amazon-s3-and-cloudfront/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amazon-s3-and-cloudfront/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/)
 * [Active Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/reviews/)

## Tags

 * [HTTPS](https://wordpress.org/support/topic-tag/https/)
 * [rewrite url](https://wordpress.org/support/topic-tag/rewrite-url/)
 * [SSL](https://wordpress.org/support/topic-tag/ssl/)

 * 4 replies
 * 2 participants
 * Last reply from: [JohnP](https://wordpress.org/support/users/johnp/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/rewrite-cname-urls-to-https-s3-amazonaws-com/#post-9551063)
 * Status: not resolved