How to load image URL with relative URL
-
I’m basically trying to replace images url so that if the webpage is loaded with https, the image url is load with https as well.
I tried this code, but it doesn’t work unfortunately
function wpse_ssl_template_redirect() { if ( !is_ssl() ) { if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) { wp_redirect(preg_replace('|^https://|', 'https://', $_SERVER['REQUEST_URI']), 301 ); exit(); } else { wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 ); exit(); } } } add_action( 'template_redirect', 'wpse_ssl_template_redirect', 1 );
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to load image URL with relative URL’ is closed to new replies.