admin管理员组

文章数量:1134549

Yesterday I moved my sites from 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.

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.

Share Improve this question asked Feb 8, 2016 at 4:41 drrileydrriley 11 bronze badge 1
  • How have you done the change? Have you followed the instructions for changing the URL of a WordPress site? – cybmeta Commented Feb 8, 2016 at 13:40
Add a comment  | 

1 Answer 1

Reset to default 0

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.

add_filter('the_content','wpse_217012',1000,1);
// 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.

本文标签: WP media attachment location vs permalink