2

I have recently installed a Drupal site on our web server and this is the default host (replaced an old website with static files). This server also hosts another virtual host for another domain name and that installation is WordPress.

On blog posts on the Drupal site (regular pages are fine), images will eventually show broken icons and when you check the URL of the image, it's replacing the domain name for the Drupal site with the domain name for the WordPress site.

Clearing the cache within Drupal immediately fixes everything, and the images reappear and with the correct URL.

An additional oddity is that the images are broken inside our network, but from the outside they will show up even though using the incorrect URL. On the inside, it resolves to the internal IP address and on the outside to the public.

I'm using Apache 2.2.22 with Drupal 7.28.

I realize it could be an Apache issue or DNS issue, but I'm checking all avenues... is there a configuration for the Drupal cache that I should be taking a look at that could be causing this problem?

3
  • I assume you have cleared your Drupal cache? I need some more details on your Drupal ENV to help you, if it multi-language? Do you have a hardcoded Drupal path in your settings.php? And other commonly asked questions.
    – Steven
    Jul 2 '14 at 20:29
  • Yes... clearing the cache fixes the problem. The images will appear again and have the correct URL. After a few hours to a few days, it crops up again. We are not using multi-language, just English. No hardcoded path in the settings.
    – paulmanac
    Jul 2 '14 at 20:54
  • The quick and dirty fix might be the CDN module. Use it to point to the correct domain for images. Fixing the root cause would be ideal
    – mikeytown2
    Jul 2 '14 at 21:40
1

The first thing you need to do is stare at your Apache access logs for a while and see if you have inbound requests to the wrong URL. You may need to configure per virtual host logfiles to see which vhost is handling which.

You may also want to disable Drupal caching (both page and block) to see if the problem persists.

My guess is that everything with your Drupal configuration is correct, but that you have inbound requests that Drupal is handling because it is the default site, and these are getting cached.

If the Apache logs indicate that Drupal is getting the wrong URL, then I would do the following:

  1. Configure both virtual hosts to respond to the canonical URL, and the redirections. Something like

    ServerName www.example.com
    ServerAlias example.com *.example.com

This will make sure the proper vhost is responding to the proper domain (which is guess is the root cause of your problem, ie you need a ServerAlias).

  1. Configure httpd.conf or .htaccess to set up canonical URL redirection for both the Wordpress and Drupal sites. Something like

    RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301]

These help ensure that Drupal and Wordpress only ever see requests for a single hostname.

These two things make good sense on most live sites, too.

If you still have the wrong URLs and you are 100% positive about the traffic, then my next guess would be that you have a misconfigured settings.php somewhere in your organization, and you have two sites / servers running out of the same database (eg, DEV and LIVE are actually using the same database). To fix this, you would need to find the offending site.

4
  • Thanks for the suggestion. The problem hasn't resurfaced yet, so I haven't checked the log files (it sometimes takes a few days before it will show itself) but I indeed did NOT have the ServerName and ServerAlias configured on the default virtual host, so perhaps that is the problem. It was configured on the WordPress site, though. We'll see if this fixes the problem.
    – paulmanac
    Jul 3 '14 at 16:22
  • @paulmanac You will likely need to combine that with the canonical URL rewrites to be effective.
    – mpdonadio
    Jul 3 '14 at 16:24
  • Thanks, I'll do that as well. Didn't want to mess with it over the holiday weekend (and it's been fine since last week) but I'll do as you suggest with that and report back.
    – paulmanac
    Jul 8 '14 at 15:53
  • Haven't had the problem creep back up in over a week, so I'm thinking this has fixed it.
    – paulmanac
    Jul 16 '14 at 15:34

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.