Your server has multiple hostnames that resolve to a single address, and you want to respond differently for www. Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site.
You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.
The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www. The above configuration is what you will want to use in almost all name-based virtual hosting situations. The only thing that this configuration will not work for, in fact, is when you are serving different content based on differing IP addresses or ports.
The server has two IP addresses. On one Any request to an address other than A request to The server machine has two IP addresses The machine is sitting between an internal intranet network and an external internet network. Outside of the network, the name server. On the internal network, one can just use the name server rather than the fully qualified host name server.
You have multiple domains going to the same IP and also want to serve multiple ports. The example below illustrates that the name-matching takes place after the best matching IP address and port combination is determined.
The server has two IP addresses In each case, we want to run hosts on ports 80 and But why not replace that with RedirectMatch Show 1 more comment. It all depends on the configuration order in this case. Wolph Wolph 1 1 gold badge 7 7 silver badges 12 12 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Related 3. Hot Network Questions. Question feed. Server Fault works best with JavaScript enabled. Accept all cookies Customize settings. If a VirtualHost doesn't specify a ServerName , a server name will be inherited from the base server configuration.
If no server name was specified globally, one is detected at startup through reverse DNS resolution of the first listening address. In either case, this inherited server name will influence name-based virtual host resolution, so it is best to always explicitly list a ServerName in every name-based virtual host. For example, suppose that you are serving the domain www. Then you simply add the following to httpd. For example, you might want to do this in order to run some name-based virtual hosts on one IP address, and either IP-based, or another set of name-based virtual hosts on another address.
Many servers want to be accessible by more than one name. Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server. The first matching ServerName or ServerAlias is used, with no different precedence for wildcards nor for ServerName vs. The complete list of names in the VirtualHost directive are treated just like a non wildcard ServerAlias.
Most directives can be placed in these containers and will then change the configuration only of the relevant virtual host.
To find out if a particular directive is allowed, check the Context of the directive.
0コメント