Hi there,

This might be a simple one for the subdomain experts. I have two Drupal installations/websites running on the same webserver. One is a public website, which runs on the root www directory, the other one runs from a subdirectory. Via the webhost's control panel we forward a subdomain (like subdomain.domain.com) to the subdirectory (to domain.com/subdirectory). My question is about the website in the subdirectory, and the wrong url alias it generates in my opinion... Because when accessing the site via subdomain.domain.com all the url aliasses (and hyperlinks/menu items) still have the subdirectory in it, like 'subdomain.domain.com/subdirectory/content-title'. I would like it to be 'subdomain.domain.com/content-title', without the subdirectory being mentioned...

The subdirectory Drupal installation seems to find that it's baseurl is subdomain.domain.com/subdirectory, instead of just subdomain.domain.com. When I try to change this in settings.php by setting the base_url variable to subdomain.domain.com, the url aliasses are like I want them to be, and even menuitems are functioning correctly, but all the links to css files, images etc. are broken. Drupal seems to search for these files in the wrong place when it's trying to open an image like subdomain.domain.com/sites/all/themes/themename/logo.png. The file can only be opened at subdomain.domain.com/subdirectory/sites/all/themes/themename/logo.png. What I am doing wrong here? Strange right?

I thought it might have something to do with http://www.fractalomega.com/node/1 and http://drupal.org/node/37645 but I'm not sure.

Hope someone can help me out here! Thanks!

Comments

cog.rusty’s picture

You have http://domain.com pointing to folder ~/domain.com
and http://subdomain.domain.com pointing to folder ~/domain.com/subdirectory
Right?

You have a ~/domain.com/subdirectory/sites/default/settings.php file which contains either

# $base_url = 'http://example.com';

disabled, or

$base_url = 'http://subdomain.domain.com';

Right?

What is that you are saying that a file should open at

subdomain.domain.com/subdirectory/sites/all/themes/themename/logo.png

? What is "subdomain.domain.com/subdirectory"? From what you said it shouldn't even exist.

Have you added any custom RewriteRules in any of the two .htaccess files?

NicoDruif’s picture

Right. And right.

I would expect Drupal to open the example logo.png at subdomain.domain.com/sites/all/themes/themename/logo.png (so without the subdirectory in the url, because it is forwarded by the webhost) but it seems to only find it at subdomain.domain.com/subdirectory/sites/all/themes/themename/logo.png (so with the subdirectory in the url).

No other custum RewriteRules added.. So I am right this is not the expected url behaviour?

Thanks for replying btw!

cog.rusty’s picture

You are right, this is not expected behavior.

Try this code in a node in the subdomain site to see what it prints:

print "Server Domain: ". $_SERVER['SERVER_NAME'] ."<br />";
print "HTTP Domain: ". $_SERVER['HTTP_HOST'] ."<br />";
print "Script path: ". $_SERVER['PHP_SELF'] ."<br />";
print "Drupal base path: ". base_path() ."<br />";
print "Drupal rel. theme path: ". path_to_theme() ."<br />";
print "Drupal rel. files path: ". file_directory_path() ."<br />";

If it prints the expected results, try running update.php to do some cleanup and rebuilding.

Also,
- put a small .txt files in the subdirectory containing "This is the subdirectory" and try to access it from the subdomain.
- check if there is a real "webroot/subdirectory/subdirectory" directory and the themes are under that (in case the subdomain really points to the subdirectory).
- check under the "webroot/sites" directory to see if, besides the "default" subdirectory, there is also a second subdirectory named "sub.example.com" which captures the second site (in case the subdomain doesn't really point to the subdirectory).

NicoDruif’s picture

Thanks man, I'll try this!

But it will be wednesday next week when I can post my findings. I'll get back to you then!

cog.rusty’s picture

Correction: Not path_to_theme() but $GLOBALS['theme_path']

NicoDruif’s picture

I didnt have the chance to try this anymore, because the client didnt really care about this. But good to know how to print all te (drupal/theme)paths anyway. Thanks!