Current time: 11-27-2024, 10:24 AM Hello There, Guest! (LoginRegister)


Thread Closed 
Redirect a subdomain to the main domain
Author Message
snoopy74 Offline
Newbie
*

Posts: 7
Joined: Sep 2009
Reputation: 0
Post: #1
Redirect a subdomain to the main domain
Again hello :o)

Creating a subdomain for an account, i have to specifiy a special directory.
Now one of my customers wants to receive all requests to a subdomain on his main domain:

sub.test1.com > test1.com

Without changing the URL to "test1.com".
Is there a possibility with .htaccess ?

I already tried:
Code:
RewriteEngine    on
RewriteRule    ^/$ /srv/www/virtual/test1.com/htdocs/

Code:
RewriteEngine    on
RewriteRule    ^/$ /test1.com/htdocs/

Code:
RewriteEngine    on
RewriteRule    ^/$ /../../htdocs/

All without success.
09-03-2009 10:40 PM
Find all posts by this user
Blondak Offline
Junior Member
*****
Dev Team

Posts: 84
Joined: May 2008
Reputation: 5
Post: #2
RE: Redirect a subdomain to the main domain
did you try
Code:
RewriteEngine on
RewriteRule ^(.*)$ http://test1.com/$1 [P]
ofcourse this must be in sub.test1.com (/srv/www/virtual/test1.com/sub1/htdocs/.htaccess)
?
(This post was last modified: 09-04-2009 12:31 AM by Blondak.)
09-04-2009 12:29 AM
Visit this user's website Find all posts by this user
snoopy74 Offline
Newbie
*

Posts: 7
Joined: Sep 2009
Reputation: 0
Post: #3
RE: Redirect a subdomain to the main domain
Code:
RewriteEngine on
RewriteRule ^(.*)$ http://test1.com/$1 [P]
returns an Error 500.

btw: Wouldn't that way not disturb my URL / request host ?

Another form of my question:
Is it possible to use the sources from "www.test1.com" for all requests for "sub.test1.com" without visible changes in the URL ?

My customer installed WordPress and changed it for multi-domain-support (Doc from http://www.yourhelpcenter.de/2009/03/wor...tallation/). Now he did not want to install WP on all subdomains and support all those copies.
09-04-2009 01:14 AM
Find all posts by this user
Blondak Offline
Junior Member
*****
Dev Team

Posts: 84
Joined: May 2008
Reputation: 5
Post: #4
RE: Redirect a subdomain to the main domain
(09-04-2009 01:14 AM)snoopy74 Wrote:  
Code:
RewriteEngine on
RewriteRule ^(.*)$ http://test1.com/$1 [P]
returns an Error 500.

btw: Wouldn't that way not disturb my URL / request host ?

Another form of my question:
Is it possible to use the sources from "www.test1.com" for all requests for "sub.test1.com" without visible changes in the URL ?

My customer installed WordPress and changed it for multi-domain-support (Doc from http://www.yourhelpcenter.de/2009/03/wor...tallation/). Now he did not want to install WP on all subdomains and support all those copies.

strange, I test it and works for me, but i think, that you can set directory to same as main domain.
09-04-2009 01:37 AM
Visit this user's website Find all posts by this user
snoopy74 Offline
Newbie
*

Posts: 7
Joined: Sep 2009
Reputation: 0
Post: #5
RE: Redirect a subdomain to the main domain
(09-04-2009 01:37 AM)Blondak Wrote:  strange, I test it and works for me, but i think, that you can set directory to same as main domain.

No, it's not possible.

Error message from ispcp:
"Mount point already in use!"

Any other ideas ?
09-04-2009 02:05 AM
Find all posts by this user
snoopy74 Offline
Newbie
*

Posts: 7
Joined: Sep 2009
Reputation: 0
Post: #6
RE: Redirect a subdomain to the main domain
Nobody ?
09-05-2009 09:37 PM
Find all posts by this user
joximu Offline
helper
*****
Moderators

Posts: 7,024
Joined: Jan 2007
Reputation: 92
Post: #7
RE: Redirect a subdomain to the main domain
Hi snoopy74

normally all subdomains (subx.domain.tld) are handled by the main domain (because the apache config has a "ServerAlias *.domain.tld" - so you don't need an extra entry for them.
(Well, then http://www.subx-domain.tld does not work - but I think this is not needed).

Otherwise I often set / as sub-older - and then the subdomain is the same as the main domain (just take care when deleting the subdomain - I don't know if the folder is removed... :-) :-)

/J
(This post was last modified: 09-05-2009 10:07 PM by joximu.)
09-05-2009 10:06 PM
Visit this user's website Find all posts by this user
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #8
RE: Redirect a subdomain to the main domain
Quote:Is it possible to use the sources from "www.test1.com" for all requests for "sub.test1.com" without visible changes in the URL ?

There is one really easy way, but it must be done as an admin because it involves filesystem fiddling:
Code:
rm -rf /var/www/virtual/domain.tld/subdomain/htdocs
mkdir /var/www/virtual/domain.tld/subdomain/htdocs
mount --bind /var/www/virtual/domain.tld/htdocs /var/www/virtual/domain.tld/subdomain/htdocs
09-06-2009 11:08 AM
Visit this user's website Find all posts by this user
joximu Offline
helper
*****
Moderators

Posts: 7,024
Joined: Jan 2007
Reputation: 92
Post: #9
RE: Redirect a subdomain to the main domain
... or symlink...
09-07-2009 04:53 AM
Visit this user's website Find all posts by this user
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #10
RE: Redirect a subdomain to the main domain
*owned* Wink
09-07-2009 10:27 AM
Visit this user's website Find all posts by this user
Thread Closed 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)