I am focusing on a drupal 6 site at mydomain.com/drupalsite, and also the designer has put lots of hardcoded image pathways inside, for example a custom img folder in mydomain.com/drupalsite/img. So many of the site uses links to /drupalsite/img/myimg1.png.
Here's the issue -- the website is eventually moving to finaldomain.com, via pointing finaldomain.com to mydomain.com/drupalsite. Now pathways like /drupalsite/img/myimg1.png will resolve to finaldomain.com/drupalsite/img/myimg1.png, rather than what ought to be finaldomain.com/img/myimg1.png. The finaldomain.com site needs to indicate that subdirectory therefore it hits the index.php.
My first instinct is by using an .htaccess file to exchange the /drupalsite with "", but I have attempted in regards to a dozen different solutions plus they haven't labored. My hack of the solution ended up being to apply certain ln -s links however i really do not enjoy it :) tia
The best way, in hindsight, would be to ensure folks use Drupal functions to create all links:
l(this is the letter L)
l() function takes proper care of base path worries, and offers an organized method to define your URL's. Using such things as
theme_image() as well as the
l() function really are a sure win. Make use of the second and third functions above if you need to write your personal
<a> tags as well as for use inside theme functions like
However for your present situation:
In regards to Andy's solution, it might be better should you could limit your changes to particular database fields in which you be aware of links are situated.
So write a question to choose all individuals fields (e.g. all body fields):
$my_query = db_query("Choose vid, body FROM ")
This, for instance, will enable you to get every
body area within the
node_revisions table, so even your old revisions might have proper links.
Then tell you individuals results, do
str_replace() on each, after which write the alterations back:
while($node = db_fetch_object($my_query)) SET body = '%s' WHERE vid = %d", $new_body, $node->vid)
I'd clearly try the fit one record first, to make certain your code reacts as intended (just give a
WHERE vid = 5, for instance, to narrow it lower to 1 revision). In addition, I've not cheated
node_save, that are better for loading and saving nodes correctly, providing a far more general solution (that you should replace text in blocks, etc.).
For the files, I'd advise a good old
sed command, by running something similar to the next from inside your "sites" folder:
find ./ -type f -professional sed -i ’s/string1/string2/’
Nabbed that came from here, so have a look on that website for additional explanation. If you are likely to be dealing with pathways, you'll either have to escape the
/ from the pathways inside your version from the
sed command, or make use of a different
sed separator (i.e. you are able to write
s#string1#string2# rather than
s/string1/string2/, which means you could write
s#/drupalsite/img/#/img# rather than
s//drupalsite/img///img/ :-). See also Drupal guide page for convenient
sed instructions: http://drupal.org/node/128513.
A little of the mess, and that's why I attempt to enforce while using proper functions in advance. But this really is difficult if you would like themers to produce Drupal content but you won't want to provide them with use of the "PHP Filter" input format, or they just have no idea PHP. Proper Drupal theming, at any time past fundamental HTML/CSS work, takes a understanding of PHP and Drupal's theme-related functions.
I have carried this out before if you take a complete database dump, opening it inside a text editor, and carrying out a global search and replace around the pathways. After that time the brand new host, load the modified dump file, and it'll possess the correct pathways in.
You could attempt Pathologic, it will have the ability to correct pathways such as this.