You may encounter an error displaying 404 unknown virtual host error. There are several ways to fix this problem, so we’ll come back to that shortly.
I place it pointing to a specific folder with our main domain and place it in a second, subdomain, targeting a different folder.
The first one has been good for centuries and the next never worked and came back together 404.
The funny thing is, when I connect to the IP, it loads the second virtual host.
ServerAdmin [email protected] Server name cropflow.com.br ServerAlias www.cropflow.com.br DocumentRoot / var / www / html / cropflow Error $ APACHE_LOG_DIR / errorlog.log $ APACHE_LOG_DIR / combined access to customlog.logRewrite engineRewriteCond% SERVER_NAME = cropflow.com.br [OR]RewriteCond% SERVER_NAME = www.cropflow.com.brRewriteRule ^ [END, NE, R = constant]
ServerAdmin [email protected] Server name api.cropflow.com.br ServerAlias www.api.cropflow.com.br DocumentRoot / var / www / html / cropflow-api / public ErrorLog $ APACHE_LOG_DIR / error.log $ APACHE_LOG_DIR / combined access to customlog.logRewrite engineRewriteCond% SERVER_NAME = api.cropflow.com.br [OR]RewriteCond% SERVER_NAME = www.api.cropflow.com.brRewriteRule ^ https: //% SERVER_NAME% REQUEST_URI [END, NE, R = persistent]
These answers are provided by our community. When you find helpful men and women, show nota lot of love by clicking a heart. If you come across any complaints, please leave a comment or add your answer to help others.
I’m sure questions like this would be welcome, but the answers available are not even very clear, so please put your suffering below me.
After configuring the
_default _ ServerName to return a 404 message. This means if explicitly Available domain is not often listed in the host’s http h2 tags, 404 is returned. (Ideally a little longer than pointing to a specific directory that does not currently exist.)
This is not exactly what virtual hosts do, I’m worried;) Virtual hosts are used to support multiple independent sites on a single web server.
/ var / www / folder. Sl For example, Apache config will set the
DocumentRoot to the expert assertions directory,
/ var / www / .
If you now target the browser
http: //www.my-site.tld/welcome.html , the file
/ var / www / welcome. html . You can use subfolders to organize your wonderful site. For example, if you point to
http: //www.my-site.tld/holidays/summer2001.html in a trusted browser, check
/ var / www / holiday / summer2001. html .
So far so good. But what if you want to create more than one website on your current computer at the same coordinate? Multiple websites under different URLs, so (if you look at children “from the outside”) are completely independent from each other, and not just very different subdirectories on the same website? This is where virtual hosts come in handy.
In a real virtual host configuration, you can create many directives not globally for a specific whole web server, but for each website. For example, suppose you host websites on the same web server, www.my-site.tld and www.my-other-site.tld. To do this, you can Use two web host configurations for *: 80> Example
DocumentRoot / var / www / my-other-site / Server name www.my-other-site.tld ServerAlias my-other-site.tld Index.html directory index CustomLog /var/log/apache2/my-other-site.access.log "combined" ErrorLog /var/log/apache2/my-other.error.log
DocumentRoot is often defined differently on each virtual device, same for
ServerName , same for
ServerAlias and soon.
I hope I can illustrate the idea of virtual hosts and why virtual servers and subdirectories are two different things in the same area. To complicate matters further, you can easily create subdirectories on the virtual web server;) Say the URL
http: //www.my-other-website.tld/tournaments/finals2015. Html si If you are using the above configuration, you must provide
/ var / www / my-other-site / Tournament / finals2015 to.html .
Other things you can withpush, I can’t go into detail here:
When you use addresses, domain names, etc., you need to know where to find them. A simple installation of
ServerName my-cool-site.com does not give the “Internet” a direct answer to requests from
my-cool-site.com 😉 Since you usually use DNS, getting the domain label (in fact, most of the time it usually has more buses, so you will need to update them from time to time) and set up a DNS record to “just in case someone” searches for
If you use the IP type instead of the sector name, for example
http://127.0.0.1/webstuff/how-dns-works.html , this cannot be changed to the principles above. If your server has assigned multiple IP addresses to it, you can differentiate between them on your virtual hosts. If your server has 192.168.2.101
assigned to this will, you can distinguish between these liquidators on your virtual hosts. applies only to 192.168 requests. 2.101
not sent on request 192.168.2.102`.
If you want to allow them to ringTo connect to your web server from the washing machine it runs on and don’t want to use a specific IP address, you can usually just say, “Show me a web page on the same host. like I am on any localhost now. “This is usually configured with the special hostname
localhost . So you can type anything directly` http: // localhost / thats-a-long-answer like .html ‘in the address field of your browser.
Usually someone has a shared “parent directory” where your virtual hosts are usually
DocumentRoot . For example, currently you can have all of your virtual hosts under
/ var / www / subdirectories. It’s not easy to use this structure, but this element is good for keeping track of things, not keeping your sites all over the place;)
Customers can use a
alias to include a directory outside the
DocumentRoot virtual host. Suppose you need to add the virtual config “www.my-site.tld” to the directive / sports like
alias / home / john / some-sports
However, in such cases, there may be problems with authorization. Files for
/ home / john / some-sports is usually owned by consumer
john , so the user can use all your web server (Apache) software as and not as possible during running have access to it.
Anyone who might need a little load is suddenly digesting, but these are some of the basic ideas you need to grasp in order to grasp them when you first start your web server.