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

    • If you can't spell a simple word that 2nd graders learn, your entire argument is suspect.
    • And here goes the "Won't someone think of the children" brigade. Get stuffed mate. This has NOTHING to do with making the internet safe. It's about tracking adults, spying on your online activity, and sending the boys around when they don't like something you post. Also, again, parliament have voted TWICE against this, and Starmer is going ahead anyway. THAT is anti-democratic bullsh**. They will use this law to track you, they will use this law to control you, and they will use this law to punish you if they don't like what you do, even if it's legal. And your data? Say bye bye to that. It'll be on the darkweb in weeks. I'm not some rando online. I've been an IT professional for 40 years, many of it in security. I know exactly what this means and what will happen to your data. I do not consent and I will not comply.
    • "...but it may not be Microsoft's fault" seems like a reasonable way to tease what is going on without leaving the user with a false impression that an update is the problem. A title isn't a summery, it is meant to entice the user to read the article. It should not contain a misleading premise; which this title does not. You could maybe complain that the first paragraph should have included that detail. The writing style popularized over 100 years ago in newspapers will cover the most important information as soon as possible with details and nuance added later; the idea being that with each new paragraph you have less of the reader's focus.
    • Samsung Galaxy XR arrives in the UK with new AI and enterprise features by Fiza Ali Samsung is bringing its Galaxy XR headset to the UK several months after the device made its debut as the first headset built on Google's Android XR platform. The headset was first teased in late 2024 alongside Google's introduction of Android XR before making its commercial debut in 2025. Developed in collaboration with Google and Qualcomm, Galaxy XR combines mixed reality experiences with Gemini-powered AI features, allowing users to interact with digital content using voice, gestures, and visual inputs. While the hardware itself remains largely unchanged from the version Samsung unveiled last year, the company is using the UK launch to spotlight several software enhancements that have arrived through recent updates. Among the most notable additions is deeper integration with Google's ecosystem. Galaxy XR users can explore destinations through Google Maps' Immersive View, receiving AI-powered recommendations and contextual information from Gemini while navigating virtual environments. Furthermore, entertainment experiences have also expanded; users can watch 180-degree and 360-degree videos on YouTube, browse spatial content converted into 3D, and ask Gemini questions about on-screen content without interrupting playback. Samsung is also highlighting mixed-reality features such as Circle to Search, which allows users to identify real-world objects through hand gestures while using the headset's video pass-through mode. Another feature automatically converts photos and videos into spatial 3D experiences. Moreover, the headset now also supports Android Enterprise, allowing organisations to manage deployments using existing Android management tools. Annika Bizon, Vice President, Product and Marketing, Mobile Experience, Samsung UK & Ireland, talked about the device, stating: The headset is powered by Qualcomm's Snapdragon XR2+ Gen 2 platform and features dual 4K Micro-OLED displays. The tech giant says that users can expect up to 2.5 hours of battery life. Samsung also confirmed that Galaxy XR will continue receiving software and security updates as the company works alongside Google and Qualcomm to expand the Android XR ecosystem. Galaxy XR is now available for pre-order and will go on sale on 8 July. Customers interested in trying the headset before launch can visit Samsung KX in London and selected Samsung Experience Stores from 17 June. Finally, the company will also host a livestream on 19 June showcasing the headset's capabilities and answering questions from prospective customers.
  • Recent Achievements

    • First Post
      Jocimo earned a badge
      First Post
    • Week One Done
      suprememobiles48 earned a badge
      Week One Done
    • One Month Later
      Windows Guy earned a badge
      One Month Later
    • One Month Later
      Prasann earned a badge
      One Month Later
    • Week One Done
      Prasann earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      519
    2. 2
      +Edouard
      174
    3. 3
      PsYcHoKiLLa
      95
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      70
  • Tell a friend

    Love Neowin? Tell a friend!