PHP – replace http with https in URL by Simple PHP script to replace http into https Here is the top answer to replace http into https <?php $url = preg_replace("/^http:/i", "https:", $url); ?>