View Full Version : .htaccess
jacauc
02-12-2006, 01:31 AM
Hi,
I would like to know how to setup .htaccess so that my main site's base folder is in a subfolder of public_html.
In other words:
/home/myaccount/public_html/subfolder1 (for my main domain)
/home/myaccount/public_html/subfolder2 (for my first addon domain)
/home/myaccount/public_html/subfolder3 (for my second addon domain)
but when I access my main domain from a browser, I do not want it to show that I am redirecting:
I want to see:
http://www.mymaindomain.com/
and not http://www.mymaindomain.com/subfolder1
Same applies to the addon domains.
Thanks!
jacauc
That's mod_rewrite (http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html) you'll need. Basicly in your .htaccess file there should be (haven't tested it:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/$ /subfolder1/$1
macklord
02-12-2006, 05:40 PM
i want to get this workin as well on my site cant seem to figure it out..
ok which htaccess file do i edit tho the root dir or the add on dir?
I tried the the code but didnt work .. i edited the add on htaccess not the root
Dustin
02-12-2006, 07:32 PM
That actually is a way to edit the .htaccess but to actually set teh DocumentRoot it's a much more difficult process. You will need to impliment mod_rewrite to achieve "Masquerading".
The process itself I'm not really sure of myself but it requires deep implimentation, and, alot of pain :P You will need to do some work with your .htaccess files, since one a shared server environment, you can't use DocumentRoot or any .htaccess extension like that.
I can take a look into it a bit and see what results I can dig up, just because I am obsessive about that kind of thing. If anyone else successfully completes masquerading please feel free to share.
jacauc
02-12-2006, 09:30 PM
Well, I would've thought everyone would want this, because without it, you'd have your addon domain subfolders mixed inbetween your main domains folders... can get cluttered :S
Is this how most people work?
That's mod_rewrite you'll need. Basicly in your .htaccess file there should be (haven't tested it:
Oh, ya - mod_rewrite would be necessary for rewriting the URL, but I'd also have to do some redirect to get to the actual page.
Is this done with the "redirect" statement, and how??
Hmm, what exactly do you want? Sounds like you just have to park the domain? I see no problem in having subfolders to my add-on domain in the main domain folder.
jacauc
02-13-2006, 04:29 AM
Well, it is a cleaner approach.
Let say "hypothetically" I want to delete the entire contents of my main domain, I could go into /public_html/subfolder1/ and execute "rm -rf"
This will delete everything in that folder including subfolders.
Now let's say I do this, but I do it in the public_html folder, I would delete everything including my addon domains.. everything!
I like it to be structured and kept seperate.
Ah, yeah. Not sure if this is possible though, but try submit a ticket at Bluehost Support (so you can have add-on domain folders at /). And tell us how it went :)
jacauc
02-13-2006, 05:36 AM
It's Just the opposite I want. Don't want addons in / I want maindomain to behave like an addon and be in a subfolder.
Dustin
02-13-2006, 06:44 AM
Our support probably wouldn't be able to help out there, as it requires detailed scripting (which, again, not even sure of 100% the actual scripting needed) so we wouldn't really be able to set that up.
I briefly looked into it last night but I will do some more research later on today.
BrandonK
02-13-2006, 06:46 AM
The only scripting I do is mIRC scripting. (5 Years) :cool:
hehe :rolleyes:
jacauc
02-23-2006, 02:32 AM
Ok, let's say I want to do the following:
I have a website under http://www.dieinter.net
(this site was lost by the previous hosting company :( - I am now awaiting the final release of Drupal 4.7 before I will redo the site)
currently, If you go to http://www.dieinter.net you will be redirected to http://www.dieinter.net/new
I have done this redirect because all the current website files are located under a subfolder called "new" under my public_html
Is it possible with .htaccess to hide the "/new" part in the URL so that the user would not know it is in that directory - the user must only see http://www.dieinter.net
Basically, i just want to make it look more professional from the browser side. The end user must not know anthing about my file structure.
Thanks again!
jacauc
casperl
02-27-2006, 03:34 AM
Hi,
I had a similar problem where I wanted all my domains in sub-folders. I fiddled quite a bit and could not do it on Bluehost.
I ended up keeping my main domain in the public_html and the sub-domains / addon domains etc in individual folders. BTW I found that every time I fiddle with the .htaccess I break something on Bluehost. I have learned to stick to the .htaccess created by Fantastico as being foolproof. For the life of me I could not see where I was wrong, but my .htaccess mods broke the system.
There is another approach however, if you insist on having your main site in a subfolder. Obtain SSH access to your account. (You will need some Linux skills to do this.) Move all the files and dirs for the main Drupal installation into a subfolder ie public_html/mysubfolder
Make a list of the content of that subfolder. Now create simlinks from public_html/ to that subfolder ie.
ln -s mysubfolder/files files
and so on for everything in mysubfolder
You will end up with the requisite number of symlinks pointing to every file in public_html/mysubfolder and it 'should' work. It is not exactly a 'neater' solution, but you do succeed in the objective of running Drupal out of a subfolder.
I did this for a while, and had various corruptions. In order to test a stable setup, I moved my main Drupal account back to public_html.
I hope this helps.
Casper Labuschagne
freact
01-22-2008, 02:01 PM
Hi,
I would like to know how to setup .htaccess so that my main site's base folder is in a subfolder of public_html.
In other words:
/home/myaccount/public_html/subfolder1 (for my main domain)
/home/myaccount/public_html/subfolder2 (for my first addon domain)
/home/myaccount/public_html/subfolder3 (for my second addon domain)but when I access my main domain from a browser, I do not want it to show that I am redirecting:
I want to see:
http://www.mymaindomain.com/
and not http://www.mymaindomain.com/subfolder1
Same applies to the addon domains.
Thanks!
jacauc
Still a fair question I think. Anyone have a solution? I'm going to be having this come up soon and I'd like to declutter the public_html main folder for several reasons.
One reason not to do this would be for search engine optimization (SEO), but thats only theoretical.
So, any solutions?
Basil
01-22-2008, 02:31 PM
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.com$ [nc]
RewriteRule ^(.*)$ /home/[your_username]/public_html/subfolder1/$1 [L]
freact
01-22-2008, 03:23 PM
I noticed in the knowledge base this solution as well:
http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=394
Thanks Basil.
Basil
01-22-2008, 03:47 PM
Yeah, the solution in the knowledgebase checks if the file or directory requested isn't there, and only applies the rewrite if it isn't. My approach was just "treat the subfolder exactly like it was the document root." Also you could just use /subfolder/$1 for the path, rather than what I put, they point to the same place.
The main difference is if somebody requests example.com/file, their version will first check if /public_html/file exists, and if it does it will serve it, otherwise it will rewrite to /public_html/subfolder/file.
What I wrote will only ever go to /public_html/subfolder/file, unless it's overridden by a lower htaccess file.
It's just a matter of preference as to which one you should use.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.