0

How to set all link to https using php or .htaccess ?

with this code

<?PHP
$path_image = "404.png";
?>
<img src="<?PHP echo $path_image; ?>">

when inspect elements it's show

<img src="404.png">

i want to change inspect view to

<img src="https://www.example.com/404.png">

How can i do that with php or .htaccess ?

peat ribersal
  • 93
  • 1
  • 7

1 Answers1

0

I suggest you use .htaccess for force redirect with SSL

Note: htaccess can not change your HTML but it can redirect to https

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

and if want to do with php than you have need to HTTP_HOST and after that manuly redirect to https://hostname/$your_url

Shiv Singh
  • 6,939
  • 3
  • 40
  • 50
  • when i use this `` it's not show green bat url but when i use `` it's show green bar url. i want to use `` and show green bar url how can i do that ? – peat ribersal Dec 08 '15 at 07:14
  • as i have told you on my answer that you can not change on html, so you have to do it manualy. so add full https hostname before images, js, css after that it will show green bar. – Shiv Singh Dec 08 '15 at 07:26