Matthew Colley
Matthew Colley

Reputation: 11446

.htaccess Image source redirection from http to https

I am attempting to change http to https for an image tag through an .htacess file.

here is the source tag

<img src="http://www.example.org/images/post_images/5879.jpg" width="510" height="315">

I want to change this to:

<img src="https://www.example.org/images/post_images/5879.jpg" width="510" height="315">

here is my .htaccess file what i have accomplished so far:

 RewriteRule ^images/(.*) https://example.org/images/$1 [R]

Upvotes: 2

Views: 8856

Answers (1)

anubhava
anubhava

Reputation: 785098

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^images/.+$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Upvotes: 3

Related Questions