logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache - multiple sites, and .htaccess
Author
Ph1L



Joined: 26 Aug 2016
Posts: 3
Location: Denmark

PostPosted: Fri 26 Aug '16 12:57    Post subject: Apache - multiple sites, and .htaccess Reply with quote

Hi,

What is the best practise for the following:

1 Linux webserver with Apache:
2 websites, at /var/www/site1 and /var/www/site2
Apache2/sited-enabled/site1.conf ->

<VirtualHost *:80>
ServerName site1.com
ServerAlias www.site1.com oldsite1.com www.oldsite1.com
DocumentRoot "/var/www/site1"
<Directory /var/www/site1/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>

site2.conf ->

<VirtualHost *:80>
ServerName site2.com
ServerAlias www.site2.com oldsite2.com www.oldsite2.com
DocumentRoot /var/www/site2
<Directory /var/www/site2/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>


I want visitors, visiting oldsite1.com, redirected to site1.com/oldsite1

And visitors, visiting site2.com to site2.com/oldsite2

And so on...
The problem now, is after making site2.conf, all visitors from oldsite1.com, gets redirected to site2.com.

Does it make sense? Smile
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Mon 29 Aug '16 12:10    Post subject: Reply with quote

Pretty easy

Code:

RewriteCond %{HTTP_HOST}   !^fully\.qualified\.domain\.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://fully.qualified.domain.name/$1 [L,R]


Replace the domain name with your.
Back to top
Ph1L



Joined: 26 Aug 2016
Posts: 3
Location: Denmark

PostPosted: Mon 29 Aug '16 14:42    Post subject: Reply with quote

So this should be:

RewriteCond %{HTTP_HOST} !^oldsite1\.com [OR]
RewriteCond %{HTTP_HOST} !^oldsite2\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://newsite.com/oldsite [L,R]

Correct?
Back to top
Ph1L



Joined: 26 Aug 2016
Posts: 3
Location: Denmark

PostPosted: Thu 22 Sep '16 12:23    Post subject: Reply with quote

Bump?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 11 Oct '16 21:48    Post subject: Reply with quote

Nope

Code:

RewriteCond %{HTTP_HOST}   !^newsite\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://newsite.com/$1 [L,R]
Back to top


Reply to topic   Topic: Apache - multiple sites, and .htaccess View previous topic :: View next topic
Post new topic   Forum Index -> Apache