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.

Comments

-Anti-’s picture

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.

-Anti-’s picture

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.

Tom Ash’s picture

That link doesn't work - I'd really love to read it, as I have the same problem! Any pointers?

-Anti-’s picture

It seems the developer has changed his autopath module settings since I posted the url:
http://www.drupial.com/content/install-drupal-subfolder

By the way, realise that I *had* to put the website in a subfolder (actually I've since switched and used a proper subdomain for various reasons). I cannot put the site in root because the space is shared with different departments of the business and we agreed that no one particular script should get to go in root; so all the various scripts are in subfolders/subdomains. If I had a choice, the site would go in root to avoid using htaccess rewrites.

This one seems to work ok, but you can never tell until a bug sneaks up and bites you.
Yes, it adds flexibility by hiding the folder or subdomain in the url, but at what cost? I don't know.