Find and replace paths within code files

Following on from my post 'Managing files when moving to multi-site in Drupal 6' where I explained about updated file paths in the files table, and other tables in the database. Here is a handy command to use if you have any hard coded image paths in code.

find ./ -type f -exec sed -i 's|sites/default/files|sites/example.com/files|' {} \;

It's best practice not to hard code image paths in your code, but it does happen, and you may have inherited a site with this issue.

Similar posts

Mailing list

Subscribe for monthly updates, blog posts, and client case studies direct to your inbox.

Twitter