Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By tepelena on
Hi all,
I have an easy question.
Looking for a way to change all the urls in the database from http to https. Basically we have hundreds on href links where the refernced image has a link such as http://www.domain.com/path-to-file.jpg
And need to change it to: https://www.domain.com/path-to-file.jpg
Basically, only http >> https part of the url needs to change.
What do I need to run in phpmyadmin to find all ref and change it?
Thank you.
Comments
UPDATE your_table
That for every field you want to change. But be very, very careful, definitely take a backup etc.
Also be careful if a db field contains a serialized array. You can't do it for values like that. The replace would break that serialized array as the string length differs after the replace.
Also note there is this module here: https://www.drupal.org/project/pathologic .. which can fix links for changed URLs on the fly for you. It might be a safer approach, as you don't risk breaking everything. :-)
I like cookies!
fix your drupal installation
All internal content in your drupal website should be using relative URLs so that changing to SSL or a different domain is painless.
There are even modules that can help with the process, which analyze and detect URLs that aren't properly formed.
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
Good point.
Good point.
I like cookies!
after fixing urls/paths
After you fix all the urls/paths in your website, try the following module, which manages making relative urls/paths within a Drupal website function correctly in all contexts.
https://www.drupal.org/project/pathologic
https://www.google.com/search?q=pathologic+module+site%3Adrupal.org
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
another similar module
Here is another of many similar modules that help maintain properly formed relative URLs in a Drupal website:
https://www.drupal.org/project/protocol_relative_urls
There are other modules also worth studying and testing for relevance to a particular need and/or site implementation.
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
Thank you all for the
Thank you all for the suggestions. Great tips for newcomers like me! :)
SSL certificate is done, but still the main site has the message
SSL certificate is done, but still the main site has the message, your connection to this site is not completely secure. even downloaded pathlogic and secure login. all the links are displaying "https" but the secure sign is not coming... Newbie to D8, please help
Chrome DevTools - Audits -
Chrome DevTools - Audits - Best Practises may give you more precise info.
Hi,
Hi,
use REPLACE. and if there is a index on the field then the UPDATE can use them
UPDATE t
set url = REPLACE(url, 'http:', 'https:')
WHERE url like 'http:%';
this will only find row with 'http://example.com%'
UPDATE t
set url = REPLACE(url, 'http:', 'https:')
WHERE url like 'http://example.com%';
UPDATE t
set url = REPLACE(url, 'http://example.com', 'https://example.com')
WHERE url like 'http:%';
It may work.
This might help, I got this
This might help, I got this from this page - https://www.drupal.org/https-information
Redirect to HTTPS with settings.php
You can also force SSL and redirect to a domain with or without www in settings.php, the benefit is that it won't get overwritten after updating Drupal. Insert this at the top of settings.php, right after <?php:
yes it will work
Yes it will work fine . but if you update your database values then it will be a bulletproof :)
This worked !!!!
Thanks @Junix33 for the solution. This worked.
Cool !
I just adapted the code for its use in copy / paste mode ;-)
Stève