Answer the question
In order to leave comments, you need to log in
Apache 2.4, can't set up name-based VirtualHost on localhost. Why 400 error?
Dear experts - I ask for help.
There is a computer under Windows 7. You need a local server on it. I used to use XAMPP, but it stopped suiting me.
I decided to install Apache2.4+PHP+mySQL separately. There were no particular problems.
But for the second day I can not configure name-based VirtualHost. those. it is necessary that at the addresses localhost, captcha_lite and, if necessary, other names - different sites open. On XAMPP it worked.
How I set it up on Apache:
Uncommented these lines in the httpd.conf file
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:/USR/www"
ServerName localhost
ServerAlias www.localhost
ErrorLog "D:/USR/log/localhost/error.log"
CustomLog "D:/USR/log/localhost/access.log" common
ServerAdmin [email protected]
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/USR/www/captcha_lite"
ServerName captcha_lite
ServerAlias www.captcha_lite
ErrorLog "D:/USR/log/captcha_lite/error.log"
CustomLog "D:/USR/log/captcha_lite/access.log" common
ServerAdmin [email protected]_lite
</VirtualHost>
Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.
With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers. Using this technique, many different hosts can share the same IP address.
When a request arrives, the server will find the best (most specific) matching argument based on the IP address and port used by the request. If there is more than one virtual host containing this best-match address and port combination, Apache will further compare the ServerName and ServerAlias directives to the server name present in the request.
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "D:/USR/www/s1.localhost"
ServerName s1.localhost
ErrorLog "D:/USR/log/s1.localhost/error.log"
CustomLog "D:/USR/log/s1.localhost/access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "D:/USR/www/s2.localhost"
ServerName s2.localhost
ErrorLog "D:/USR/log/s2.localhost/error.log"
CustomLog "D:/USR/log/s2.localhost/access.log" common
</VirtualHost>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question