I’ve got a WordPress install that is serving up content via both HTTP and HTTPS. The site URL is configured as “http://www.example.com”. This works for most situations – if a person requests a page at “https://www.example.com/page” the page is served up via HTTPS.
However, the challenge that I’m facing is that there are a number of WordPress template functions which pull the site URL (like get_bloginfo(‘stylesheet’) ) and when they do that, they include “http://” in the returned results. Similarly, images that are inserted in the WYSIWYG editor have the “http://www.example.com…” path hard coded.
What I’d really like to do is find a way to define the base site URL as “//www.example.com”, which would hopefully make everything work correctly. However, the WordPress admin fields won’t support this.
Does anyone have any ideas how to do this?
2 Answers
An easy solution is to use .htaccess rules.
#Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]