Posted by eliza411 on November 4, 2009 at 12:32am
Back in the 4.7 days, I recall that installing drupal in a subdirectory could cause major headaches with some of the contrib modules and was in general kind of a pain. Has anyone worked with drupal in a subdirectory in D6 recently? If so, I'd really appreciate hearing about your experience.

Comments
The Drupal Camp PDX site was
The Drupal Camp PDX site was running in a sub directory. In terms of modules, it's pretty much a non-issue in 6. However, it can still blow up in content if the directory gets renamed (eg, hard-coded links to /foobar/sites/default/files/, or hard-coded links to nodes, etc, will not be automatically updated).
Use Drupal path functions to always find your files
If you run into cases where you have those previously mentioned hard-coded links, replace them with one of the drupal functions to get paths. For example:
file_directory_path()drupal_get_path('module', 'my_module_name');drupal_get_path('theme', 'my_theme_name');I was talking about those
I was talking about those paths in content, and it's not really practical to tell people they need to write every node in php so they can use those functions ;)
Dev-Specific
Good point, my comment above is more applicable when developing a theme or module that references a file somewhere.
No serious issues in either 5 or 6
This has not been a major issue for us for the last couple years.
Cheers,
Bill
FunnyMonkey
The only module that I am
The only module that I am aware of that cannot be in a subdirectory install is Domain Access
Issues with FCKEditor
I had an issue a few months back with FCKEditor's handling of relative URLs on a site located in a subdomain. You'd like that setting the base URL correctly in the settings.php file would solve this, but I actually had to change the base URL in the .htaccess file. Not really sure why. But it worked. ;)
No problems that I've seen
I have several sites with Drupal 6 in a subdirectory with no problems.
The only issue I've run into was with a multisite installation hosted at hotdrupal.com. All my secondary sites were working just fine there (mostly different domains, not subdomains), but when I finally got the Drupal version of the primary domain on my account ready to go (converting from my old static site), it would not work. I tried all sorts of things with no success. When I finally called Hot Drupal, Steve's solution was to move the Drupal installation up one level to the root public_html folder. Then everything was finally copacetic. But I speculate that it may have been as much an issue with the particulars of how Hot Drupal had things configured (because of their special handling of the primary domain on the account) as it was anything inherent to Drupal. But that's the only multisite installation I have going, so no "control group".
drupal_get_path to get "foobar"
Hi Tyler,
My site lives in a subdirectory but using drupal_get_path seems not getting path with /foobar in the beginning. I've got .htaccess with RewriteBase /foobar set and $base_url=http://127.0.0.1/foobar in settings.php. And I think the Drupal instance itself knows it lives in a subdirectory because settings.php in sites/127.0.0.1.foobar/ is in effect.
Actually everything works fine on my drupal site in subdirectory. Just drupal_get_path() seems missing the /foobar as you mentioned. So I am wondering if I missed something, although I've done some googling.
Cheers,
Burke
Need more info
Hi Burke,
I don't feel like I understand your situation well enough to answer your question. Can you please send the line of code where you are using drupal_get_path() with the parameter values, along with the exact output that the function is returning? Also it might help to know what you are trying to accomplish with this function, as maybe there is a better way.
Cheers,
here it is
Hi Tyler,
Thank you for your message. I am using the classification module of EOL LifeDesks which can be downloaded here:
http://www.lifedesks.org/modules/downloads/classification.tar.gz
The LifeDesks team developed it in a subdomain setup, but I am trying to use it in a subdirectory drupal. Please see classification.module line 119, which is coded as:
then at line 122 & 125, the $path is used to call an icon, magnifier.gif, and maybe others elsewhere, as I am still studying the code.
My drupal lives in /webDocumentRoot/foobar. (The classification module works fine if drupal is not living in a subdirectory.) Now with Eclipse+debugger, I can see the $path is returned as "sites/all/modules/lifedesks/classification/", therefore as least line 122 & 125 couldn't get the icon.
So I am wondering what should I do to make $path returning "foobar/sites/all/modules/lifedesks/classification/" by using drupal_get_path. Because your previous message seemed said so.
Hope this is clear to you. But I don't expect you to review the whole module. It has been very kind of you to take a look at this. If line 119 is fine, then I think there might be something wrong so drupal_get_path couldn't return the path with the subdirectory name.
Once again, thanks!
Burke
Try Absolute Path
So I haven't downloaded or opened it, but it sounds like you are getting a path relative to the base install of your drupal instance, which is getting used to output the URL of an image, and so I'm assuming that the resulting symptom is that the icon img tag has a src which is not found and does not render in the HTML output. In this case, try outputting the complete URL for the image, by starting with the $base_url, then add on a "/" and the rest, like:
$path = $base_url . "/" . drupal_get_path('module', 'classification') . '/';
So that what you used to get: sites/all/modules/lifedesks/classification/
Turns into: http://path_to_your_site.com/foobar/sites/all/modules/lifedesks/classifi...
You may have to do that for every place that it is building up HTML for the images, and get bonus points for creating patch of your changes and giving to the authors. :)
Thanks Tyler, this is exactly
Thanks Tyler, this is exactly what I am doing as a temporary solution. But I thought drupal_get_path automatically returns subdirectory name "foobar/" by default. That's why I was wondering maybe there were other settings wrong in my drupal setup. Then I guess I misunderstood your comment, http://groups.drupal.org/node/33584#comment-102984
Misleading
Hey Burke,
Sorry if that previous comment was misleading. To clarify, the drupal_get_path() returns the path relative to the base_url of the stie, so the 'foobar' references should be taken out of my earlier comment. HTH
Thanks for clarifying
Thanks, Tyler! It could be my poor English to understand the comment well. Anyway, I am glad that it's been clarified so I can look for other workouts to help with the code for subdirectory setup. I appreciate your time on this. :)
Cheers,
Burke