PDA

View Full Version : Pointing Main Domain to Different Directory


Ghost
10-09-2006, 09:20 AM
Is there a way to point my primary domain to something beneath /public_html/?

I plan on having several addon domains, but I don't want any of them to be reachable through the main domain. For instance, if I have main domain abc.com, and addon domain def.com set to /publich_html/_def, I don't want people being able to go to www.abc.com/_def.

lrbaldwin
10-09-2006, 11:08 AM
If you have an index.html in your main directory for that domain name, nobody should be able to view any other files in that folder or any subfolders.

Linda

Ghost
10-09-2006, 11:12 AM
I could technically prevent people from viewing files in the directory by adding Options -Indexes to the .htaccess file. But neither way prevents someone from manually typing in the subdirectory and going there.

Pethens
10-09-2006, 03:10 PM
If you are really determined to solve this problem, I think you could do something with some mod_rewrite rules in your .htaccess file. You would just need a rule that rewrites maindomain.com/subdomainname to maindomain.com, for each subdomain. See here:

http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

It will take a little work to figure it out though. I doubt that it's worth it, because the odds of someone finding one of your subdomains by typing random urls is actually quite low.

Stephen

Ghost
10-09-2006, 03:16 PM
Using mod_rewrite will work, and should be pretty easy. I guess my main problem is that it seems messy to have the directories/files for separate domains contained in the same folder as the files for my primary domain. So I was just wondering if there's some way via BlueHost's cPanel to change that -- but so far at least, it appears there isn't; so the organizational side of me will just have to live with it. :)

areidmtm
10-09-2006, 03:41 PM
this is what I use in my htaccess.

This points my main domain to /public_html/domainname/


RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule !^domain(/.*)?$ /domain%{REQUEST_URI} [QSA,L]


OR something more complicated:


RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/domain/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /domain/$1/
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ domain/index.php [nc]


This way my public_html folder looks like:

maindomain
addon1
addon2
addon3
etc....

Ghost
10-09-2006, 05:31 PM
Wouldn't that cause visitors to see http://www.domain.com/domain in the URL bar of their browser when they go to http://www.domain.com though? I know I'm being picky, but I'm sorta OCD when it comes to that sorta thing. :)

areidmtm
10-09-2006, 05:39 PM
Wouldn't that cause visitors to see http://www.domain.com/domain in the URL bar of their browser when they go to http://www.domain.com though? I know I'm being picky, but I'm sorta OCD when it comes to that sorta thing. :)

No. It does a silent redirect. You will only see http://www.domain.com/ in the bar

Ghost
10-09-2006, 05:57 PM
Aweome, I wasn't aware of the invisible redirect trick (still learning the tricks of Apache). Thanks for the tip, this works like a charm!

thomasw98
11-22-2006, 09:59 PM
My question is how will Google and other search engines see an add-on domain under my main domain and how will they index it? It would be very bad if the search engines indexed it as:

www.maindomain.com/addondomain/file.html

That would basically destroy the "hidden" aspect you have been discussing above as anybody searching in Google would discover that addondomain.com was not a "real website" and instead just a subfolder of "maindomain.com".

If that was not bad enough, another problem is that the search engine links would be permanently indexed in google, so if you ever switched back to a properly structured site, all of the previously indexed links (such as the example above) would be invalid.

I really HOPE this is not the case. Can anybody tell me the real answer???

Thanks,

Thomas

thomasw98
11-24-2006, 04:24 PM
My question is how will Google and other search engines see an add-on domain under my main domain and how will they index it? It would be very bad if the search engines indexed it as:

www.maindomain.com/addondomain/file.html

That would basically destroy the "hidden" aspect you have been discussing above as anybody searching in Google would discover that addondomain.com was not a "real website" and instead just a subfolder of "maindomain.com".

If that was not bad enough, another problem is that the search engine links would be permanently indexed in google, so if you ever switched back to a properly structured site, all of the previously indexed links (such as the example above) would be invalid.

I really HOPE this is not the case. Can anybody tell me the real answer???

Thanks,

Thomas

Well, for the record, from what I can tell so far, it seems that everything is ok. Google indexes pages on the addon domain as www.addon.com/file.html.

skycpu
11-29-2006, 01:22 PM
If you are really determined to solve this problem, I think you could do something with some mod_rewrite rules in your .htaccess file. You would just need a rule that rewrites maindomain.com/subdomainname to maindomain.com, for each subdomain. See here:

http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

It will take a little work to figure it out though. I doubt that it's worth it, because the odds of someone finding one of your subdomains by typing random urls is actually quite low.

Stephen
I also have the same problem. my main domain is www.abc.com
my addon domain is www.ttt.com.
how to achieve the result that they can see www.ttt.com when the users input www.ttt.com
how to do something with some mod_rewrite rules in my .htaccess file?
I read your said, but I donot know what is going on?
do u have any tutorial for that ?

Pethens
11-29-2006, 02:10 PM
I also have the same problem. my main domain is www.abc.com
my addon domain is www.ttt.com.
how to achieve the result that they can see www.ttt.com when the users input www.ttt.com?

I think you have misunderstood, because what you're describing is the way it works automatically. If someone enters www.addon.com to go to your addon domain, that's what they will see in the location bar. You don't need to do anything special to make this happen. If somebody types in www.addon.com and they see www.maindomain.com/addon in the location bar, contact support because there is a problem with your account.

The mod_rewrite rules I was discussing are for a different purpose: they are so that noone can type www.maindomain.com/addon and go to your addon domain. Areidmtm posted some rules that will fix this issue if it matters to you.

Hope that helps

skycpu
11-29-2006, 02:33 PM
I think you have misunderstood, because what you're describing is the way it works automatically. If someone enters www.addon.com to go to your addon domain, that's what they will see in the location bar. You don't need to do anything special to make this happen. If somebody types in www.addon.com and they see www.maindomain.com/addon in the location bar, contact support because there is a problem with your account.

The mod_rewrite rules I was discussing are for a different purpose: they are so that noone can type www.maindomain.com/addon and go to your addon domain. Areidmtm posted some rules that will fix this issue if it matters to you.

Hope that helps


Firstly, thanks for your help!


However, I had my addon domain yesterday. I cannot open it when I input

www.addon.com. Strangely, I can input www.maindomain.com/addon so that I may read it.
what is wrong with my addon?

Pethens
11-29-2006, 03:32 PM
You're welcome ;) The most likely cause for your addon domain not working is that the DNS entries have not yet propagated for it. I would give it 24-48 hours. Then, if you still have problems you can do a whois query here:

http://www.networksolutions.com/whois/index.jsp

Check that your name servers are ns1.bluehost.com and ns2.bluehost.com. If not, a mistake was made setting up your add-on domain. You will need help from Bluehost support.

Stephen

thomasw98
11-29-2006, 05:54 PM
You're welcome ;) The most likely cause for your addon domain not working is that the DNS entries have not yet propagated for it. I would give it 24-48 hours. Then, if you still have problems you can do a whois query here:

http://www.networksolutions.com/whois/index.jsp

Check that your name servers are ns1.bluehost.com and ns2.bluehost.com. If not, a mistake was made setting up your add-on domain. You will need help from Bluehost support.

Stephen

Just to share my experience:

The DNS propagation process is always very hard to predict. Sometimes they propagate in 15 minutes, and sometimes in more than 48 hours.

Sometimes the propogate only partially so, for example, people in the USA can reach the website, but people in China can not access it for another 48 hours. In such a situation, if I check networksolutions whois, it will show that the DNSs have been changed to ns1.bluehost.com and ns2.bluehost.com, but people in China still can not access the website because the DNS's have not propagated all the way to their ISP's servers yet.

In other words, it is always a bit hard to predict for the first 24-48 hours what is actually happening.

skycpu
11-29-2006, 09:22 PM
You're welcome ;) The most likely cause for your addon domain not working is that the DNS entries have not yet propagated for it. I would give it 24-48 hours. Then, if you still have problems you can do a whois query here:

http://www.networksolutions.com/whois/index.jsp

Check that your name servers are ns1.bluehost.com and ns2.bluehost.com. If not, a mistake was made setting up your add-on domain. You will need help from Bluehost support.

Stephen


thanks a lot!

skycpu
12-01-2006, 05:48 PM
You're welcome ;) The most likely cause for your addon domain not working is that the DNS entries have not yet propagated for it. I would give it 24-48 hours. Then, if you still have problems you can do a whois query here:

http://www.networksolutions.com/whois/index.jsp

Check that your name servers are ns1.bluehost.com and ns2.bluehost.com. If not, a mistake was made setting up your add-on domain. You will need help from Bluehost support.

Stephen



hi there,

Now I have new question .


Until now, I cannot access my addon domain(eg.www.def.com)
I only can access www.maindomain.com/def OR def.maindomain.com

I asked bluehostsupport center, they just reply:

1.Although you did add the domain as an addon domain, you have yet to register the domain with a registrar. What you could do is login to your domain manager, click on list domains, and click on the transfer button. At this point it will prompt you to register the domain.(first reply lettle)

2.The ability to have 5 addon domains is free, but we do not cover the registrations for those additional domains. Additional domains are $10/year if registered through us.(second letter)


From two letter above , it mean that I should pay $10 per year if I want to have a addon domain on the basic of my main domain.

However, the bluehost advertisement said a acount includes 1 main domain and 5 addon domain. I thought it is free for 5 addon domain after paid main domain fee per year

So it confuse me!

thomasw98
12-01-2006, 05:54 PM
Did you register ownership of def.com with a domain registration company yet?

If not, you need to do that now. You can use bluehost to register the name, and they will charge you per year. Or you can use another company such as namecheap.com to register it for you.

As I understand, bluehost does include one free domain name registration with each basic account. So you should be able to register this for free through bluehost UNLESS you have already used up your one free registration.

The 5 addons are included BUT you should understand that having an addon domain space is different from registering a domain name. Here's an overview:

For your main domain, you need to register the name then get server space. You have already done this it seems.

For each addon domain, you need to first register the new domain name, THEN setup the addon space on your bluehost account.

hope that helps!

skycpu
12-01-2006, 06:11 PM
Did you register ownership of def.com with a domain registration company yet?

If not, you need to do that now. You can use bluehost to register the name, and they will charge you per year. Or you can use another company such as namecheap.com to register it for you.

As I understand, bluehost does include one free domain name registration with each basic account. So you should be able to register this for free through bluehost UNLESS you have already used up your one free registration.

The 5 addons are included BUT you should understand that having an addon domain space is different from registering a domain name. Here's an overview:

For your main domain, you need to register the name then get server space. You have already done this it seems.

For each addon domain, you need to first register the new domain name, THEN setup the addon space on your bluehost account.

hope that helps!


Thanks!

I understand it as a whole

thomasw98
12-01-2006, 06:15 PM
By the way, I should mention that it is my own personal policy never the register domain names via the same company that I use for webhosting. In other words, don't register domain names via bluehost if you are using bluehost for hosting your domains. Not that I have anything against bluehost, but I have heard many horror stories from other people who decided the change to new hosts and suddenly found that their domain names were somehow held hostage by the former hosting company. Again, I have never heard of any similar problems with bluehost, and so far they seem like a very open and upright organization (just the fact that they have an open forum is a big confidence builder in my opinion).

skycpu
12-01-2006, 06:45 PM
By the way, I should mention that it is my own personal policy never the register domain names via the same company that I use for webhosting. In other words, don't register domain names via bluehost if you are using bluehost for hosting your domains. Not that I have anything against bluehost, but I have heard many horror stories from other people who decided the change to new hosts and suddenly found that their domain names were somehow held hostage by the former hosting company. Again, I have never heard of any similar problems with bluehost, and so far they seem like a very open and upright organization (just the fact that they have an open forum is a big confidence builder in my opinion).


I have got new question from your said:

Now I sign up a year with bluehost, so that I have a domain names such as www.abc.com

After one year, I would like to change another hosting company,
may I own this domain namewww.abc.com

thomasw98
12-01-2006, 07:02 PM
If you never registered ownership of the domain name "abc.com" before, and then you signed up with bluehost, I would assume that what happened was:

1. They registered the domain name abc.com for you. You are now the owner of this domain name. They registered it for FREE for you because they offer this nice gift to attract you to sign up for their hosting service.

2. They created a webhost server space for you to host abc.com.

OK, so now everything is fine. But if you decide to move to a new webhost in a year, as I understand, bluehost will not allow you to move this domain to a new host UNLESS you pay for the domain registration fee of abc.com (Remember the fee was originally free, but if you want to move away from bluehost, they will then charge you for this registration fee). You can probably read more details about this in the service section of the bluehost website.

skycpu
12-01-2006, 07:11 PM
my god, that is trick.


anyway, thanks for taking your time:)

I know what I should do next


by the way, do u know what company have this service(register domain name )?

I know one company www.namecheap.com, anything else?
How about www.fastdomain.com?

thomasw98
12-01-2006, 07:54 PM
Well, it is not really a trick since they clearly state this requirement during the signup process.

To answer your second question: I always use namecheap. I used godaddy once but had some problems and service was not very good.

areidmtm
12-01-2006, 08:17 PM
All domains that you get from bluehost are registered IN YOUR NAME, not bluehosts name, even if you use the domain privacy. YOU own the domain, not bluehost.

Hope that clears things up.

Also this thread is getting off topics and basically has been resolved. If you still need help, make a new topic.