How can I replace all my internal links automatically? I have changed the domain of my website from www.mysite.com to mysite.net. I upload the site to the new domain and all is fine, but I have more than one thousand nodes, and in almost all the nodes I have a link to another node on the site.

The link are absolute so they have this form: www.mysite.com/node/22 and I need to change all nodes to the new domain.

Changing 1,000 links manually is too much. How can I do this automatically??
Why are you using absolute links? If you were using relative links, of the form /node/22, the problem would not arise.

I am assuming you are using Drupal 7. The answer for D6 would be a little more complex.

If the links are in the node body, and if you have direct access to your database, you can update the text by running a query on the field_data_body and field_revision_body tables.

First, back up your database in case this goes wrong.

Then run the following query on your tables:

UPDATE field_data_body SET body_value = REPLACE( body_value, 'a href="http://www.mysite.com/','a href="http://mysite.net/');


Repeat with the field_revision_body table.

This should change all references to the old domain with the new domain.

If you have links in the comments, you might also want to do field_data_comment_body and field_revision_comment_body, scanning for references in the comment_body_value field.

In the event the links are being generated automatically by a text filter, change the REPLACE patterns accordingly.