1

I copied a website from the server to local environment and after seeing that everything is displayed I noticed that the images in all blog posts are not being displayed. I googled this problem and found that a lot of people had it before me and tried applying their ways to solve the problem but none of them were successful for me. I think I am missing something. Please correct me if there is something I might have missed. Here's a list of things I have done

  1. Compared the image paths and both are the same src="/sites/default/files/image.jpg"
  2. Checked the .htaccess file in sites/default/files and no differences there too
  3. Cleaned the cache

It is not a multisite and it is drupal ver 7.31

  • Do you have on your test of environment on subdirectory ? For instance localhost/testswebsite. Or you have it installed on localhost like if you are going to the test by going to localhost ?. On what is running your localhost ? Did you check the files permission are ok ? – darol100 Jan 22 '15 at 17:43
  • I use MAMP and access the website by going to localhost/folder/ files permissions are set to be 644 – AntK Jan 22 '15 at 18:15
2

The reason you are having the problem is because you have your website on localhost/folders. And you Drupal installation expects your website to be in locahost. So there is to easy ways to solve this problem. Either you move everything up directory and all your files are in the localhost.

cd /Applications/MAMP/htdocs/testwebsite # Move to the website folder directory.
sudo mv * .[^.]* .. # Move everything up one directory.
cd .. # Move to localhost directory.
sudo rm -rf testwebsite     # Remove testwebsite directory.

Or you can created a temporary soft link on your localhost so your Drupal installation can find the sites folder on the localhost.

cd /Applications/MAMP/htdocs/ # Move to the webserver directory.
sudo ln -s testwebsite/sites sites/ # This is going to created the soft link .
  • I just moved everything up a directory so I can access the website by going to localhost. However the images still do not appear – AntK Jan 22 '15 at 19:02
  • Did you clear caches ? – darol100 Jan 22 '15 at 19:31
  • How has this question/answer/thread languished for over 2 years with not a single up/down vote?! Drupal Answers is a barren wasteland... :-/ I imagine this answer should work, and hopefully it did since he/she didn't comment again after it. Beyond that, I'd say to double check the public,private and tmp folders that are listed in the admin file systems to make sure they have the appropriate permissions. – UnsettlingTrend Apr 14 '17 at 14:36
  • Creating the soft link worked for me as a temporary solution. I tried all the others methods I found online such as .htaccess, base_url, etc... But nothing worked. – Zythyr Jul 29 '17 at 3:15
0

just change the image paths src="/sites/default/files/image.jpg" to src="sites/default/files/image.jpg"

and it will work

  • I also noticed that. but if there's over 100 images manual changing is not really an option. I am sure there is a workaround for it – AntK Jan 22 '15 at 13:35
  • you can do it by rules module but you need to write a PHP code which will get the current URL for image and replace it with new one so just create new rule 1-event on display content 2-action execute PHP code and add your PHP code – JavaTrainner Jan 22 '15 at 13:53
-2

You can create a virtual host in apache in the same way it was done on your server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.