Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: Apache - multiple sites, and .htaccess |
|
Author |
|
Ph1L
Joined: 26 Aug 2016 Posts: 3 Location: Denmark
|
Posted: Fri 26 Aug '16 12:57 Post subject: Apache - multiple sites, and .htaccess |
|
|
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? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Mon 29 Aug '16 12:10 Post subject: |
|
|
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
|
Posted: Mon 29 Aug '16 14:42 Post subject: |
|
|
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
|
Posted: Thu 22 Sep '16 12:23 Post subject: |
|
|
Bump? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Tue 11 Oct '16 21:48 Post subject: |
|
|
Nope
Code: |
RewriteCond %{HTTP_HOST} !^newsite\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://newsite.com/$1 [L,R]
|
|
|
Back to top |
|
|
|
|
|
|