subfolder annoyance

-Anti- - May 13, 2008 - 21:02

I installed drupal into a subfolder: public_html/website
Then I used rewrite to redirect the domain to the subfolder:

# 301 redirect to subfolder
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ http://www.domain.com/website [R=301,L]

So www.domain.com typed into the browser bar redirects with www.domain.com/website/ shown in the browser.

Adding a page: http://www.domain.com/website/node/add/page
Looking at your account: http://www.domain.com/website/user/1

You can see the annoyance. I've looked at about 50 pages of htaccess solutions to try to rewrite the url so that the user NEVER knows that they're in a subfolder, but the best ones were only very partially successful - they only worked some of the time. Most of the solutions just porked the site.

The most annoying thing about this is that I have set up a multisite using a subdomain and a symlink, and the users see beautiful urls such as:

http://www.sub.domain.com/node/add/page
http://www.sub.domain.com/user/1

without worrying or fussing over htaccess rewrites at all.

Any comments or assistance would be appreciated.

One idea at the back of mind is this: My home/user/ directory has a 'folder' called www, which seems to be a symlink to public_html (?). Perhaps if I change www to symlink to public_html/website instead, then the domain might automatically load the website without having to redirect it with a rewrite (and so, like the subdomain, the subfolder would not be part of the url)? I assume I would still be able to ftp directly into public_html. However, I'd hate to try to change the www symlink if it broke my hosting account; does anyone know if it would?

Thanks.

symlinking www doesn't work

-Anti- - May 13, 2008 - 21:18

One idea at the back of mind is this: My home/user/ directory has a 'folder' called www, which seems to be a symlink to public_html (?). Perhaps if I change www to symlink to public_html/website instead, then the domain might automatically load the website without having to redirect it with a rewrite (and so, like the subdomain, the subfolder would not be part of the url)? I assume I would still be able to ftp directly into public_html. However, I'd hate to try to change the www symlink if it broke my hosting account; does anyone know if it would?

I renamed home/www and created a symlink from www to public_html/website.
But it didn't work. I don't know what the original www folder (or symlink) is there for, but it doesn't redirect the domain request to public_html like I thought it might.

I think the only way to use this idea would be to rename public_html to 'public', and create a symlink called public_html linking to public/website. That sounds a bit too dangerous though; isn't it?

Any other ideas would be welcome.

Got it!

-Anti- - May 13, 2008 - 22:51

Finally!!!

After roughly 30 hours (over three days) of hairpulling it seems I have achieved:

A subdomain-driven multi-site, with:
- drupal installed in a sub-folder
- urls which never reveal the sub-folder to the user
- clean urls enabled on the main site and the subdomain sites
- sessions being retained if the base url is changed (ie. deleting or adding 'www' or 'http://')

I've logged how I finally managed to get the multi-site running in other posts.
This was the final key to getting rid of the subfolder from the url was at:
http://www.drupial.com/content/drupial-installing-drupal-a-subfolder

I hope the development of my sites don't get much harder than that.
I mean, awesome capability from Drupal, but what a nightmare to set-up!

A big thanks to the drupallers who helped me.

 
 

Drupal is a registered trademark of Dries Buytaert.