Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Apache setup - Mix of testing & live sites
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Apache setup - Mix of testing & live sites
Apache setup - Mix of testing & live sites
01-07-2010 10:55 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I've setup the following:
Apache webserver setup on my home linux build which is setup with virtual hosts for:
Test Website 1 (live site hosted externally - horrbile site built by someone else I just helped the guy move it from his old host)
Test Website 2
Live Website 1 (hosted on my home linux build) & the Test website for this Live Site.
I have configured the hosts file so they resolve all website addresses internally and have configured DNS for the Live Website which I am going to host and I have tested it and it can be accessed from pc's external to my internal network. Port 80 has been opened and forwarded correctly though I guess you got that from my last sentence.
Great I thought however snag in the tail is that if someone were to enter my IP address they are taken to Test Website 1 which shouldn't be public facing. Any ideas how I get anyone entering the ip address of my site to be taken to the Live Website 1 which I'm hosting?
Apache webserver setup on my home linux build which is setup with virtual hosts for:
Test Website 1 (live site hosted externally - horrbile site built by someone else I just helped the guy move it from his old host)
Test Website 2
Live Website 1 (hosted on my home linux build) & the Test website for this Live Site.
I have configured the hosts file so they resolve all website addresses internally and have configured DNS for the Live Website which I am going to host and I have tested it and it can be accessed from pc's external to my internal network. Port 80 has been opened and forwarded correctly though I guess you got that from my last sentence.
Great I thought however snag in the tail is that if someone were to enter my IP address they are taken to Test Website 1 which shouldn't be public facing. Any ideas how I get anyone entering the ip address of my site to be taken to the Live Website 1 which I'm hosting?
Message 1 of 7
(1,012 Views)
6 REPLIES 6
Re: Apache setup - Mix of testing & live sites
02-07-2010 9:28 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Depends a little on the setup, but, if I understand you correctly, you should be able to fix that with a rewrite. Something like
in the htaccess of test website 1 - or the same with the / removed from infront of the $1 in your conf.
(remembering rewriteengine on and you may need to followsymlinks)
Gabe
RewriteCond %{HTTP_HOST} ^123\.123\.123\.123
RewriteRule (.*) http://www.domain.co.uk/$1 [R=301,L]
in the htaccess of test website 1 - or the same with the / removed from infront of the $1 in your conf.
(remembering rewriteengine on and you may need to followsymlinks)
Gabe
Message 2 of 7
(359 Views)
Re: Apache setup - Mix of testing & live sites
02-07-2010 9:52 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
As a rule, the first declared VirtualHost in the apache configuration files will be served in response to 'unknown' named virtual hosts.
Are they all set up as /etc/httpd/conf.d/*.conf files?
If so, I would make sure that your primary live website is served first (rename the xxxx.conf file to __xxxx.conf or something that puts it alphabetically first in the directory, or include the vhost config directly into httpd.conf, before the Include conf.d/*.conf line)
B.
Are they all set up as /etc/httpd/conf.d/*.conf files?
If so, I would make sure that your primary live website is served first (rename the xxxx.conf file to __xxxx.conf or something that puts it alphabetically first in the directory, or include the vhost config directly into httpd.conf, before the Include conf.d/*.conf line)
B.
Message 3 of 7
(359 Views)
Re: Apache setup - Mix of testing & live sites
02-07-2010 10:21 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
You each have your cat. Let skinning commence. 
Would probably still want to canonicalize, but could use a negative condition.
Gabe

Would probably still want to canonicalize, but could use a negative condition.
Gabe
Message 4 of 7
(359 Views)
Re: Apache setup - Mix of testing & live sites
02-07-2010 10:37 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Thanks guys.
Gabe I wasn't sure where to look on the apache user guide for this as I wasn't sure to describe the issue however I must admit the use fo the word canonicalize had me intrigued so I searched it along with apache and got this link:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html
which should explain your first reply much better.
Barry I did wonder if it was going in alphabetic order as the test being served from the ip address is the first alphabettically and you are right regarding the location.
I will do the rename however I will certainly look at Gabe's as I think it is something worth the learning.
Thanks again.
Gabe I wasn't sure where to look on the apache user guide for this as I wasn't sure to describe the issue however I must admit the use fo the word canonicalize had me intrigued so I searched it along with apache and got this link:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html
which should explain your first reply much better.
Barry I did wonder if it was going in alphabetic order as the test being served from the ip address is the first alphabettically and you are right regarding the location.
I will do the rename however I will certainly look at Gabe's as I think it is something worth the learning.
Thanks again.
Message 5 of 7
(359 Views)
Re: Apache setup - Mix of testing & live sites
02-07-2010 1:08 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I agree with Gabe regarding the cat skinning!
However, IMO this is certainly an Apache configuration issue. Moving the 'fix' to use rewriting could potentially conflict with other rewrite rules that you may require in the future, so I'm all for keeping it as simple as possible
Cheers
B.
However, IMO this is certainly an Apache configuration issue. Moving the 'fix' to use rewriting could potentially conflict with other rewrite rules that you may require in the future, so I'm all for keeping it as simple as possible

Cheers
B.
Message 6 of 7
(359 Views)
Re: Apache setup - Mix of testing & live sites
02-07-2010 3:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
In this instance, I'm struggling to think of a potential conflict.
For a name-based setup, I wouldn't normally put a live site in the default vhost, and my own preference is to declare explicitly how to treat calls for the ip address (and to point them at a you-can't-get-there-from-here page if there's more than one live vhost).
It's also a canonical-urls issue. With two or more http_hosts pointing at the same place it's still going to require either the same rewrite or a catch-all to canonicalize.
Gabe
For a name-based setup, I wouldn't normally put a live site in the default vhost, and my own preference is to declare explicitly how to treat calls for the ip address (and to point them at a you-can't-get-there-from-here page if there's more than one live vhost).
It's also a canonical-urls issue. With two or more http_hosts pointing at the same place it's still going to require either the same rewrite or a catch-all to canonicalize.
Gabe
Message 7 of 7
(359 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Apache setup - Mix of testing & live sites