HTaccess - redirection

HTaccess - redirection

am 28.03.2005 18:32:52 von Alan

Hi,

I am trying to run multiple sites from one server,

Currently I have a main domain and a subdomain, I want to point a
second domain to the server and have the subdomain work as a normal
site.

In my htaccess file I have:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*secondSite\.co\.uk$
RewriteRule ^(.*)$ http://www.secondSite.mainSite.co.uk/$1 [R=301,L]


It kind of works, but any links in the site start with
secondsite.mainSite.co.uk/, when I just want it to be
secondsite.co.uk/

Is there any way to completely mask it so the it will work as a
seperate site?

Re: HTaccess - redirection

am 28.03.2005 19:07:12 von Gabriel Reid

aland wrote:
> Hi,
>
> I am trying to run multiple sites from one server,
>
> Currently I have a main domain and a subdomain, I want to point a
> second domain to the server and have the subdomain work as a normal
> site.
>
> In my htaccess file I have:
>
> RewriteEngine on
> RewriteCond %{HTTP_HOST} ^.*secondSite\.co\.uk$
> RewriteRule ^(.*)$ http://www.secondSite.mainSite.co.uk/$1 [R=301,L]
>
>
> It kind of works, but any links in the site start with
> secondsite.mainSite.co.uk/, when I just want it to be
> secondsite.co.uk/
>
> Is there any way to completely mask it so the it will work as a
> seperate site?

Yes, there is a way (or multiple ways). I think that the easiest way to
accomplish what it looks like you're trying to do is with name-based
Virtual Hosts. Using Virtual Hosts will let Apache do the work that
you're doing by writing those mod_rewrite rules.

For full details, please refer to
. I think
something like the following should work for you:

#================================================
NameVirtualHost *


ServerName mainsite.co.uk
DocumentRoot /www/mainsite



ServerName secondsite.co.uk
DocumentRoot /www/secondsite

#=================================================


Hope this helps.

Gabriel

Re: HTaccess - redirection

am 29.03.2005 12:18:09 von Alan

Sorry, I should have said, its on a hosted server so I can't add
virtual hosts myself.


Gabriel Reid wrote in message news:<4RW1e.48964$TH1.3934253@phobos.telenet-ops.be>...
> aland wrote:
> > Hi,
> >
> > I am trying to run multiple sites from one server,
> >
> > Currently I have a main domain and a subdomain, I want to point a
> > second domain to the server and have the subdomain work as a normal
> > site.
> >
> > In my htaccess file I have:
> >
> > RewriteEngine on
> > RewriteCond %{HTTP_HOST} ^.*secondSite\.co\.uk$
> > RewriteRule ^(.*)$ http://www.secondSite.mainSite.co.uk/$1 [R=301,L]
> >
> >
> > It kind of works, but any links in the site start with
> > secondsite.mainSite.co.uk/, when I just want it to be
> > secondsite.co.uk/
> >
> > Is there any way to completely mask it so the it will work as a
> > seperate site?
>
> Yes, there is a way (or multiple ways). I think that the easiest way to
> accomplish what it looks like you're trying to do is with name-based
> Virtual Hosts. Using Virtual Hosts will let Apache do the work that
> you're doing by writing those mod_rewrite rules.
>
> For full details, please refer to
> . I think
> something like the following should work for you:
>
> #================================================
> NameVirtualHost *
>
>
> ServerName mainsite.co.uk
> DocumentRoot /www/mainsite
>

>
>
> ServerName secondsite.co.uk
> DocumentRoot /www/secondsite
>

> #=================================================
>
>
> Hope this helps.
>
> Gabriel

Re: HTaccess - redirection

am 29.03.2005 18:17:31 von Gabriel Reid

aland wrote:
> Sorry, I should have said, its on a hosted server so I can't add
> virtual hosts myself.

Okay, well then the following should hopefully work (although I haven't
tested it, and it requires mod_proxy).

#=================================================
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*secondSite\.co\.uk$
RewriteRule ^(.*)$ http://www.secondSite.mainSite.co.uk/$1 [P,L]
#=================================================


By the way, it's generally considered poor (n)etiquette to top-post.

Gabriel

>
> Gabriel Reid wrote in message news:<4RW1e.48964$TH1.3934253@phobos.telenet-ops.be>...
>
>>aland wrote:
>>
>>>Hi,
>>>
>>>I am trying to run multiple sites from one server,
>>>
>>>Currently I have a main domain and a subdomain, I want to point a
>>>second domain to the server and have the subdomain work as a normal
>>>site.
>>>
>>>In my htaccess file I have:
>>>
>>>RewriteEngine on
>>>RewriteCond %{HTTP_HOST} ^.*secondSite\.co\.uk$
>>>RewriteRule ^(.*)$ http://www.secondSite.mainSite.co.uk/$1 [R=301,L]
>>>
>>>
>>>It kind of works, but any links in the site start with
>>>secondsite.mainSite.co.uk/, when I just want it to be
>>>secondsite.co.uk/
>>>
>>>Is there any way to completely mask it so the it will work as a
>>>seperate site?
>>
>>Yes, there is a way (or multiple ways). I think that the easiest way to
>>accomplish what it looks like you're trying to do is with name-based
>>Virtual Hosts. Using Virtual Hosts will let Apache do the work that
>>you're doing by writing those mod_rewrite rules.
>>
>>For full details, please refer to
>>. I think
>>something like the following should work for you:
>>
>>#================================================
>>NameVirtualHost *
>>
>>
>>ServerName mainsite.co.uk
>>DocumentRoot /www/mainsite
>>

>>
>>
>>ServerName secondsite.co.uk
>>DocumentRoot /www/secondsite
>>

>>#=================================================
>>
>>
>>Hope this helps.
>>
>>Gabriel