SQL替换

I understand – you want to go the opposite direction and replace relative URLs with absolute ones. Here’s the SQL command to do that:

sqlCopyUPDATE wp_posts 
SET post_content = REPLACE(
    post_content, 
    'wp-content/uploads/', 
    'http://mydomain.com/wp-content/uploads/'
)
WHERE post_content LIKE '%wp-content/uploads/%';

This query:

  1. Looks for content with relative URLs starting with ‘wp-content/uploads/’
  2. Replaces them with absolute URLs starting with ‘http://mydomain.com/wp-content/uploads/‘

Just replace “mydomain.com” with your actual domain name before running this query.

If your relative URLs sometimes have a leading slash like “/wp-content/uploads/”, you’ll need to run this additional query:

sqlCopyUPDATE wp_posts 
SET post_content = REPLACE(
    post_content, 
    '/wp-content/uploads/', 
    'http://mydomain.com/wp-content/uploads/'
)
WHERE post_content LIKE '%/wp-content/uploads/%';

As before, I recommend:

  1. Backing up your database first
  2. Testing on a development environment before running on production
×
SQL替换

SQL替换

I understand - you w...

查看更多

AI agent 如何翻译网站(标签+动态内容)

先让AI把网站进行i18n化, …