0

I have a website that used to work with HTTP for 12 years. Current database is about 6-7 years old with small modifications, but content is this old and all news entries have images inside it's content (it's news website).

Now I want to go for HTTPS but I have a problem. Images are requested over HTTP because links to images are stored this way in database.

Is there a way to make all these requests switch to https without actually going to database and changing all these links to https?

Current version of website is developed using Laravel 4.

I've already added this to .htaccess.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Vuk Stanković
  • 7,864
  • 10
  • 41
  • 65
  • 2
    You can redirect them, but browsers will still complain about it because the initial request will go over http. Your only option is to change the hardcoded links (if you can make just links without a protocol or a domain this would be a plus). – Wrikken Nov 26 '14 at 22:45
  • 2
    As Wrikken said. Your images shouldn't include `http:` for most cases. `//` works for the current protocol, like: `//www.domain.com/img/image.jpg` or using the root path, like `/img/image.jpg`. – Devon Bessemer Nov 26 '14 at 22:48
  • thanks. Its fairly obvious solution, but id didn't cross my mind. Will try it – Vuk Stanković Nov 27 '14 at 23:20

1 Answers1

0

You're almost there. A quick search with 'redirect' instead of 'rewrite' returns this: How to redirect all HTTP requests to HTTPS

In summary:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Community
  • 1
  • 1
mwotton
  • 2,170
  • 18
  • 36