简体   繁体   中英

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

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM