rewrite http to https not only in url and html, but also jpg gif image files

Discussion in 'Apache' started by hyjlmc, Jun 15, 2010.

  1. #1
    Hi,
    I tried to search online for several hours and I only found how to use .htaccess to change http to https, but i did not found the information on how to make the images file like jpg, gif, png and other files like css, js, swf and so on to https.
    When i change only my url to https, in browser will show warning said that some content may not transfer via SSL. I don't want this warning came.
    I tried to check the website like https://www.google.com and the google image is in https mean. How can I do that ?
    Please help.
    Thank you.

    Regards,
    MC
     
    hyjlmc, Jun 15, 2010 IP
  2. netload

    netload Member

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Try this rule:

    RewriteEngine on

    RewriteCond %{SERVER_PROTOCOL} ^HTTP/
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

    But some hosting providers use light front-end (like nginx) in front of apache and give back image files without apache, in this case your task is undecidable.
     
    netload, Jun 15, 2010 IP
  3. hyjlmc

    hyjlmc Peon

    Messages:
    363
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,
    I received this error :
    Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

    Any other solutions?

    Thank you.

    Regards,
    MC

     
    hyjlmc, Jun 15, 2010 IP
  4. netload

    netload Member

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #4
    May be

    RewriteCond %{SERVER_PROTOCOL} ^HTTP/1\.0
     
    netload, Jun 15, 2010 IP
  5. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Try This

    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}
    
    Code (markup):

    or

    
    RewriteCond %{HTTP_HOST} ^domain.com [NC]
    RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
    
    Code (markup):
     
    roopajyothi, Jun 17, 2010 IP