Yesterday I moved my sites from http://www.example.com to (secure site and removed the www). Now when I look at an attachment page I see the File URL as the old http://www ... but the page permalink at https://.

I have even deleted the original photos and re-uploaded new ones, thinking that might solve it, but it does not. The domain is properly set (https://) in Wordpress Settings/General. The site works fine ... and the switch to https went much more smoothly than I had anticipated ... except for this issue.

Has anyone encountered similar? Or know what/where I need to change something?

Thank you for any info/advice.


I think a possible solution could be following codesnippet from Mark Kaplun.

To solve issues with this you could remove the http part and Wordpress will/should use https instead.

Because the rest of your website is working correctly I assume that further settings are correct and will do their job as wished.

// remove 'http:' part from any mention of the site url
function wpse_217012($content) {
    return str_replace(siteurl(),str_replace('http:','',siteurl()),$content);

Please add the snippet to functions.php (make a copy first) or to a plugin.

Note: Of course is this a solution to achieve a positive result and actually not pointing on the cause of your problem as it. I personally would not use a redirect done by code in .htaccess because, as mentioned by yourself already, the rest is working.
Maybe there is a plugin or own code somewhere in functions.php which is causing the problem? Please take also a look at these possibilities.

If I am totally wrong, please let me know and I will remove the answer to prevent other users here on wpse will use the (incorrect)code for an equal problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.