Fix broken links or mixed content (Database search and replace)

To fix broken links and mixed content on a website after it has gone live or received an SSL certificate, you can run an SQL query to update all content on the site. Here's how:

  1.    Open PHPMyAdmin through your hosting control panel, such as cPanel or Curanet.
  2.    Navigate to the SQL tab.
  3.    Insert the following SQL query, modifying the variables to suit your specific case. For example, to replace 'http://tannlegebaggethun.no.linux82.curanetserver.dk/' with 'https://tannlegebaggethun.no/', use:
    UPDATE template1_posts
    SET post_content = REPLACE(post_content, 'http://tannlegebaggethun.no.linux82.curanetserver.dk/', 'https://tannlegebaggethun.no/');

    Ensure that your query targets the correct table. In this example, it updates the template1_posts table. If your table uses a different prefix, adjust accordingly. For instance, if your table prefix is wp_, the query should reference wp_posts instead of template1_posts.
  4. Click "GO" at the bottom right to execute the query.

Additional SQL Queries:


  1. Referencing WebP images, if they exist:
    UPDATE template1_posts
    SET post_content = REPLACE(post_content, '.jpg', '.jpg.webp');

Important Considerations:

  • Backup Your Database: Before running any SQL queries, it's crucial to back up your database to prevent potential data loss.
  • Test Changes: After executing the queries, thoroughly test your website to ensure that all links are functioning correctly and that there are no mixed content warnings.
  • Use of Plugins: For WordPress users, plugins like "Better Search Replace" can simplify this process by allowing you to search and replace URLs directly from the WordPress dashboard.
By following these steps, you can effectively resolve broken links and mixed content issues on your website.