Apache VHosts


Recommended Posts

Hi all,

All of my current VHosts work as they should, but I'm trying to get it to display a 'default' host if there is no VHost for that domain, which doesn't appear to work. I've put it on the end of my VHosts on here but I've also tried putting it as the first host. Any advice would be appreciated! :)

<VirtualHost conquerinternet.com:80>
	DocumentRoot /home/conquerinternet.com
	ServerAlias *.conquerinternet.com
</VirtualHost>

<VirtualHost d14.info:80>
	DocumentRoot /home/d14.info
	ServerAlias *.d14.info
</VirtualHost>

<VirtualHost dannybeckett.co.uk:80>
	DocumentRoot /home/dannybeckett.co.uk
	ServerAlias *.dannybeckett.co.uk
</VirtualHost>

<VirtualHost enterpriseali.com:80>
	DocumentRoot /home/enterpriseali.com
	ServerAlias *.enterpriseali.com
</VirtualHost>

<VirtualHost fluxriver.com:80>
	DocumentRoot /home/fluxriver.com
	ServerAlias *.fluxriver.com
	# Force to use HTTPS
		RewriteEngine On
		RewriteCond %{HTTPS} off
		RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

<VirtualHost fluxriver.com:443>
	DocumentRoot /home/fluxriver.com
	ServerAlias *.fluxriver.com
	DirectoryIndex default.php index.php
	# SSL certificate
		SSLCertificateFile /home/ssl/fluxriver.com/crt
		SSLCertificateKeyFile /home/ssl/fluxriver.com/key
		SSLCertificateChainFile /home/ssl/fluxriver.com/ca-bundle
		SSLEngine on
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /home/default
	ServerAlias *
	ServerName default
</VirtualHost>

Link to comment
https://www.neowin.net/forum/topic/718598-apache-vhosts/
Share on other sites

#the asterisk here is in replacement of an IP address, not a hostname
<VirtualHost *:80>
	DocumentRoot /home/conquerinternet.com
#this is how you name a vhost
	ServerName conquerinternet.com
	ServerAlias *.conquerinternet.com
</VirtualHost>

If memory serves, apache will simply serve the first vhost as the default if it doesn't find a match in your definitions.

Link to comment
https://www.neowin.net/forum/topic/718598-apache-vhosts/#findComment-590379144
Share on other sites

  • 4 weeks later...

Apologies in the delay in thanking you for this, I've literally just got round to playing with Apache. Got it fixed partially thanks to Kudos and partially thanks to the Apache documentation. My VHOSTs are now working properly (:D) with the following config:

Listen *:80
NameVirtualHost *:80

<VirtualHost *:80>
	DocumentRoot /home/default
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /home/conquerinternet.com
	ServerName conquerinternet.com
	ServerAlias *.conquerinternet.com
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /home/d14.info
	ServerName d14.info
	ServerAlias *.d14.info
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /home/dannybeckett.co.uk
	ServerName dannybeckett.co.uk
	ServerAlias *.dannybeckett.co.uk
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /home/enterpriseali.com
	ServerName enterpriseali.com
	ServerAlias *.enterpriseali.com
</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /home/fluxriver.com
	ServerName fluxriver.com
	ServerAlias *.fluxriver.com
	# Force to use HTTPS
		RewriteEngine On
		RewriteCond %{HTTPS} off
		RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

<VirtualHost *:443>
	DocumentRoot /home/fluxriver.com
	ServerName fluxriver.com
	ServerAlias *.fluxriver.com
	DirectoryIndex default.php index.php
	# SSL certificate
		SSLCertificateFile /home/ssl/fluxriver.com/crt
		SSLCertificateKeyFile /home/ssl/fluxriver.com/key
		SSLCertificateChainFile /home/ssl/fluxriver.com/ca-bundle
		SSLEngine on
</VirtualHost>

Link to comment
https://www.neowin.net/forum/topic/718598-apache-vhosts/#findComment-590504114
Share on other sites

Ever considered VirtualDocumentRoot? It can map all of the domains dynamically so that all you essentially have to do is create a folder (this assumes the domain is already pointing to your server). You would still need the SSL config; the HTTPS redirect could be placed in .htaccess for the site, and if I'm not mistaken, you'd have to still define the default site.

Link to comment
https://www.neowin.net/forum/topic/718598-apache-vhosts/#findComment-590504158
Share on other sites

Ever considered VirtualDocumentRoot? It can map all of the domains dynamically so that all you essentially have to do is create a folder (this assumes the domain is already pointing to your server). You would still need the SSL config; the HTTPS redirect could be placed in .htaccess for the site, and if I'm not mistaken, you'd have to still define the default site.

You should only consider doing this if you find you are often reloading the config files to add vhosts.

Link to comment
https://www.neowin.net/forum/topic/718598-apache-vhosts/#findComment-590504492
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Age 16, old enough to get a full-time job, your own bank account, a passport, get married, even join the military and go to war. But talking to your friends on the internet? Oh hell no!
    • I remember when all games had demos; it was a normal thing, not a limited time promotion.
    • Forza Horizon 6 gets big bug-fixing and balancing update by Taras Buria Today, Playground Games released a big Forza Horizon 6 update with a long list of fixes, patches, and balancing tweaks that the studio promised earlier. Version 375.327 is now available on Steam, Microsoft Store, and Xbox, offering users improvements for AI, audio, design, performance, road discovery, upgrades, visuals, online play, and more. Some of the most notable changes in the Series 2 update include rebalanced drivatars, particularly their difficulty and race start behavior. As such, the game should be more balanced on higher difficulty levels, and AI cars should not shoot out when the race starts as if they have rocket boosters. Speaking of difficulty, developers nerfed Drag Tires physics for a more expected and realistic behavior. They are no longer the go-to option for record-breaking times in road racing, and all leaderboard entries with drag tires will be removed. Completionists will also be glad to get a new feature that lets you see road discovery percentage in each region, which should make discovering all roads easier while keeping it quite challenging and interesting (I spent quite a long time finding the last road). Festival Playlist is also getting some much-needed fixes, including patches for bugs that allowed completing Seasonal Jobs ahead of time or where weekly challenges would not unlock for some players. Developers will retroactively give reward points to all who could not complete all challenges due to these bugs. Other changes include changes to Horizon Play progression so that it is easier to reach Level 100, audio improvements on lower-spec devices, fixes for visual glitches, including pixelated smoke, and more. Developers also addressed the currently non-working Eliminator, an online mode gamers used to farm credits with a Hummer EV exploit. Playground Games plans to re-enable it soon. As a gesture of goodwill, players will get a free McLaren Sabre. Those who used the exploit will not be banned, but developers plan to roll back credits to a maximum of 10M for all who farmed credits using the exploit. You can find the complete changelog for the latest Forza Horizon 6 update here.
    • "Samsung is shutting down yet another app used by millions" I will fix the clickbait title for you, free-of-charge: "Samsung shutting down it's Max VPN app"
  • Recent Achievements

    • First Post
      Cosminus earned a badge
      First Post
    • One Year In
      ThatGuyOnline earned a badge
      One Year In
    • Week One Done
      Jeroen Wilms earned a badge
      Week One Done
    • Week One Done
      rolfus earned a badge
      Week One Done
    • One Month Later
      Leroy Jethro Gibbs earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      483
    2. 2
      +Edouard
      187
    3. 3
      PsYcHoKiLLa
      122
    4. 4
      Steven P.
      85
    5. 5
      neufuse
      73
  • Tell a friend

    Love Neowin? Tell a friend!