How to point subdomain to domain root

claude001

New member
Joined
Jan 3, 2012
Messages
4
I purchased a new hosting package with directadmin and have the following problem:

My domain mysite.com points to

../domains/mysite.com/public_html

My subdomain sub.mysite.com points to

../domains/mysite.com/public_html/sub

But I need that the subdomain as well points to

../domains/mysite.com/public_html


It is not about redirecting or stealth techniques.
I need for both

mysite.com
sub.mysite.com

point to

../domains/mysite.com/public_html

showing in each case the domain or subdomain name in the adress bar.

I need that as my script decides depending on the server name php variable which template and functions should be loaded.

Any help on this is very welcome, besides this problem i am really satisfied with directadmin !

Claude


And..YES I searched the forums up and down, but did not find a working solution.
Please understand that so I have to ask how to resolve that.
 
Thank You, but ...

.. I know about htaccess and mod rewrite but I do not see a way to achieve the desired behaviour. As well I couldnt find one post here explaining it well or step by step. (What does not say that this post does not exist).

.. I already asked my hoster..

.. and here in the posts I only found, that this is a feature request for directadmin ..

.. however, if You have an working solution, please let me know..

.. there must be a working solution .. I hope ;)

kind regards

Claude
 
That is rather not the right place to ask how to write mod_rewrite rules to achieve the desired. As for me I have no a solution to be implemented on User Level, I even do not have anything more to suggest you. I could write a solution for Admin (root), but not User Level.

So if you don't know how to use mod_rewrite, you should really use Google to find ready examples or read the documentation.

If your hosting company does not want to help you, you'd better move to another one, which would help you with a pleasure.
 
Thank You ..

..again, but it is not that I do not know how to redirect through htaccess, and I as well know how to use google.

I am simply asking for a feature which directadmin obviously does not have.

However, I found that through directadmin I could add the subdomains as domain as alias and then pointing them to the main folder. If there is no better aproach I could try that. It would just cost me the whole available domains in my package.

The hoster is working on that and I am confident that they find a way how to resolve that.

But sincerely, I would really prefer to know what is recommended by directadmin team it self, as workarounds are not the best thing on the long run.

So, if there is somebody who knows how to resolve that, I would be still very interested. There are several posts about subdomain pointing but I couldnt find the "golden" one.

Thank You Claude
 
Problem solved !

Thank You again for Your hints, the problem is solved now without redirecting.

Regarding my special needs and my setup the team from www.medialayer.com where I purchased that hosting package which uses directadmin told me to do the following:

Delete my subdomains from the subdomain menu and add them as pointers to my main domain in the pointers menu.

That worked perfectly and all problems are gone !

I am very interested and confident about working with directadmin as it is very easy to use for me !

Thanks again
Claude
 
I've implemented your solution, Claude and it does point the subdomain to the root. So it works perfect!

BUT... I experienced that the pointers always carries an 'www.' in front of it.

So: "sub.domain.ext" only points to the root of "domain.ext" if I type "WWW.sub.domain.ext".

When I look at the interface of the "add new domain pointer"interface I see

_______________________________________
http://www. [______] --> sourcedomain.com
_______________________________________


Is there any way around that preceding "www" that seems to accompany a pointer always?

Thanks for everybodies help!
 
BTW

If I type "sub.domain.ext" it says
_________________________
Apache is functioning normally
_________________________

So it looks like its not even reaching the .htaccess.
 
Hi Alex,

Thanks for your help. I already had pointed the subdomain, so that part I already implemented, coming from Claude and the topic you linked (I already saw your anwser there and tried it before starting a topic here). Strangely, only the 'www' variant worked on my VPS. Therefore my question here... :-)

And strangely, it started working perfectly an hour after I posted the question here... So there was some caching stuff (or something like it) going on.

But you were right! It works like a charm... :-) Thanks again.

Taking this feature further >> now I have to add all subdomains by hand (or by script) into DA. No problem with a couple of subdomains.

What if I have 100 or more subdomains, which are more or less dynamically?

Can I add something in the config or the admin level to have all subdomains pointed to the root? I know how to do it with htaccess, but undefined subdomains are not reaching the htaccess yet, I think.

Any suggestions are welcome. Thanks!
 
OK, it seems DNS needed time to get updated, propagation time.

As for adding a bulk of sub-domains... hmm you'd need to write a script (which would use Directadmin API)...
 
@both of you: good ideas! I'm am going to play with both suggestions. Thanks for your help.
 
I've implemented your solution, Claude and it does point the subdomain to the root. So it works perfect!

BUT... I experienced that the pointers always carries an 'www.' in front of it.

So: "sub.domain.ext" only points to the root of "domain.ext" if I type "WWW.sub.domain.ext".

When I look at the interface of the "add new domain pointer"interface I see

_______________________________________
http://www. [______] --> sourcedomain.com
_______________________________________


Is there any way around that preceding "www" that seems to accompany a pointer always?

Thanks for everybodies help!

I meet the same problem like you and try this way but I doesn't work.
When I added subdomain as a pointer to main domain, I get 502 bad gateway error in my main domain. ( added it as alias)
sorry for bumping this thread
 
Back
Top