Skip to main content
Virtual hosts let you give each local project its own domain name instead of accessing everything under http://localhost/. With a virtual host, your project at C:\projects\myapp\ becomes accessible at http://myapp.local/, making it easier to test realistic URLs and work with multiple projects simultaneously.

How to add a virtual host

1

Right-click the Bearsampp tray icon

Find the Bearsampp icon in your Windows system tray and right-click it.
2

Open the Apache menu

Hover over Apache in the context menu.
3

Click Add a virtual host

Click Add a virtual host. A dialog opens with two fields.
4

Enter the server name

In the Server name field, type the local domain you want to use (e.g. myapp.local). The dialog pre-fills test.local as a placeholder.
5

Set the document root

Click Browse next to the Document root field and select the folder containing your project files. This is the folder Apache will serve when the domain is requested.
6

Click Save

Click Save. Bearsampp creates the virtual host configuration file and an SSL certificate, then restarts Apache automatically.
The server name must be a valid domain name. Use a format like myapp.local — a bare name like myapp without a dot will be rejected. The .local suffix is a common convention for local development.

What Bearsampp creates

When you save a virtual host, Bearsampp does two things:
  1. Creates a config file at bearsampp\vhosts\myapp.local.conf containing the Apache <VirtualHost> block.
  2. Generates an SSL certificate for the server name and stores it in bearsampp\ssl\.
Apache is then restarted to load the new configuration.

Add the domain to your hosts file

After creating the virtual host, you must tell Windows to resolve the domain to your local machine. Without this step, your browser will try to look up the domain on the internet and fail. You can do this with the HostsEditor tool included in Bearsampp, or by editing the hosts file manually.
1

Open HostsEditor from the tray

Right-click the tray icon → ToolsHostsEditor.
2

Add an entry

Add a new entry mapping 127.0.0.1 to your virtual host domain (e.g. myapp.local) and save.

Editing the hosts file manually

1

Open Notepad as Administrator

Press Start, search for Notepad, right-click it, and choose Run as administrator.
2

Open the hosts file

In Notepad, open the file at:
C:\Windows\System32\drivers\etc\hosts
3

Add the entry

At the end of the file, add a new line in this format:
127.0.0.1   myapp.local
4

Save the file

Save the file. No restart is required — the change takes effect immediately.
Once the hosts file is updated, open http://myapp.local/ in your browser to access your project.

Edit a virtual host

To change the configuration of an existing virtual host:
  1. Right-click the tray icon → ApacheEdit [servername].
  2. The config file opens in your configured text editor.
  3. Make your changes, save the file, and restart Apache from the tray menu.

Delete a virtual host

  1. Right-click the tray icon → ApacheEdit [servername].
  2. Click Delete in the dialog.
  3. Confirm the deletion. Bearsampp removes the .conf file and restarts Apache.
Deleting a virtual host from the Bearsampp menu removes the config file at bearsampp\vhosts\, but does not delete the SSL certificate from bearsampp\ssl\ or remove the entry from your hosts file. You can clean those up manually if needed.