Opened 9 years ago
Closed 5 years ago
#40336 closed defect (bug) (wontfix)
Links to media files not updating with SSL activation and/or preferred domain change
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.7.3 |
| Component: | Media | Keywords: | close |
| Focuses: | Cc: |
Description
I have recently activated SSL encryption on one of my websites. Everything works fine, everything gets loaded just fine except that the links on images and media files that lead to them don't update.
All images inside a post load as expected in thumbnail form, clicking on them to view the full size with lightbox leads to an error where the file can't be found. The link still contains the http://www.XXX.com version of the file location.
In my case in particular, I have set https rewrites in .htaccess so it only loads the https version, and have setup in the main settings that the website&wordpress address is the non-www https version.
It was truly a surprise to me to see that the links aren't relative but absolute.
Change History (5)
#2
@
9 years ago
- Keywords close added
Hi @only1andrewh, welcome to WordPress Trac! Thanks for the report.
It was truly a surprise to me to see that the links aren't relative but absolute.
It's a design decision, see the handbook entry for more details.
As noted above, it's not really feasible for WordPress to update links in post content automatically, but it can be done with WP-CLI or Database Search and Replace script.
#3
in reply to:
↑ description
@
9 years ago
Replying to only1andrewh:
In my case in particular, I have set https rewrites in .htaccess so it only loads the https version, and have setup in the main settings that the website&wordpress address is the non-www https version.
It was truly a surprise to me to see that the links aren't relative but absolute.
Setting up SSL is actually pretty easy these days. And you hit one of the biggest things that people miss (the htaccess force rewrite rule). That's really good news!
The two things you missed are:
- To change the Settings to HTTPS. This is important so WordPress knows where to send people without even hitting the 301.
- To do a database rewrite (like others have pointed out) make sure you use your full domain or you'll change links you have in your site that point to other sites. Ex: http://yourdomain.com to https://yourdomain.com. (NOT http:// to https://).
This isn't really a bug. Just configurations that need to be set in a certain way.
Hi @only1andrewh,
I can tell you from personal experience that updating site hosts actually ends up being a bit of a heavy task. Occurrences can be sprinkled all over the database (not just certain columns of certain tables), and in many cases might be "serialized", requiring data to be pulled into PHP, updated, and pushed back (rather than just running the conversion entirely in MySQL).
I'm sure that's why WP doesn't do it automatically.
If you have command-line access to your server, WP-CLI makes the task really easy: http://wp-cli.org/commands/search-replace/
/path/to/wp-cli search-replace 'http://mydomain.com' 'https://mydomain.com' --all-tables-with-prefix