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.

Simple SEO PDF guide

Get our latest PDF guide, Simple SEO.

Similar posts

Mailing list

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

Twitter