0

So there's a site I need to redesign for a client. This website is currently in Drupal 6 (yes I know). I've installed a copy of this website in my computer using MAMP and I am able to run the website without problem.

However, all image files are broken. I've checked the path and they are pointing to:

http://localhost:8888/sites/all/themes/mytheme/images/image.jpg

instead of

http://localhost:8888/mywebsite/sites/all/themes/mytheme/images/image.jpg

Is there something I need to change in the Drupal admin in order to re-assign the correct image path? Some configuration I might be missing? There are a lot of images so manually doing this would be a pain.

Thanks a lot for your help!

3 Answers 3

2

It could potentially be solved by just adding a Virtualhost in your httpd.conf

In /Applications/MAMP/conf/apache/httpd.conf, add the following Virtualhost to the very bottom.

<VirtualHost *:80>
  ServerName mywebsite.sandbox
  DocumentRoot /path/to/mywebsite/on/Mac
  <Directory /path/to/mywebsite/on/Mac>
    Options FollowSymLinks
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/mywebsite-error.log
  CustomLog /var/log/apache2/mywebsite-access.log combined
</VirtualHost>

The path, for example, would be the absolute path on your computer. So if you keep all of your sites in a Development folder in your Documents, it would look something like this.

/Users/USERNAME/Documents/Development/mywebsite

In /etc/hosts, add the server name.

127.0.0.1 mywebsite.sandbox

Restart MAMP and you should be good to go using http://mywebsite.sandbox

0

Thats just because every image they have referenced has an src beginning with "/sites/..." so the preceding slash before the sites will be going to the root.

I guess you have to either sit your whole site on the root of your local host, to match the src of the images, or during development, copy the image directory into a sites folder on the root.

It isn't something you can change in Drupal settings to change all image paths, as they will have probably written the img src themselves, instead of the files being in the default /sites/default/files directory.

1
  • It might be worth creating a virtual machine so that you can host this website in the webroot. Alternatively, you could set up a virtual site in MAMP and set your hosts file accordingly. It really depends how comfortable you are doing these things.
    – Graham
    Mar 11, 2014 at 18:26
0

The dirty answer is to make a symlink to the 'mywebsite/sites/all...' directory from the root of your MAMP install (the link called 'sites' of course). You may need to alter your Apache config to allow symlinks to be followed.

A slightly more elegant solution, but much more of a headache is to use rewrites in your Apache config to send a URL matching 'sites/all...' to 'mywebsite/sites/all...'.

You could also modify the $base_path global for Drupal, but you would need to do this before any other bootstrap processes, which would require a core hack (you do not want to do this), and would mean you would have to remember to change it everytime you updated and/or change it back once you finished developing. Again, you do not want to do this.

Most people using Drupal for their websites have only Drupal running their website, no static content, or images, css, js, or other files outside of the Drupal framework. It seems as though only developers need/want/have to think about these issues ... le sigh :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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