Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EbrahemSamer's avatar

How to fix 400 bad request while create local domain PHP native?

I have multi local website but working on localhost like chat.com, blog.com and so on

I wanted to add one more but It says Bad request Your browser sent a request that this server could not understand.

vhosts

` <VirtualHost *:80> ServerName online_cv.com DocumentRoot "C:\xampp\htdocs\ccccc"

<Directory "C:\xampp\htdocs\ccccc">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
`

and i added 127.0.0.1 cccc.com in apache hosts

0 likes
3 replies
guybrush_threepwood's avatar
Level 33

You need to duplicate the entire block, including the VirtualHost:

<VirtualHost wp1.localhost:80>
DocumentRoot "c:/xampp/htdocs/wp1"
ServerName wp1.localhost
<Directory "c:/xampp/htdocs/wp1">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost wp2.localhost:80>
DocumentRoot "c:/xampp/htdocs/wp2"
ServerName wp2.localhost
<Directory "c:/xampp/htdocs/wp2">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

And then add the entries to your windows Hosts file (C:\WINDOWS\system32\drivers\etc\hosts):

127.0.0.1        wp1.localhost
127.0.0.1        wp2.localhost
siangboon's avatar

i believe that you can either use different unique host name with same port 80 (<VirtualHost chat.com:80>, <VirtualHost blog.com:80>) or wildcard hostname with different unique port (<VirtualHost *:8000>, <VirtualHost *:8100>) in each virtual host section but not <VirtualHost *:80> for all....

1 like

Please or to participate in this conversation.