How to set up local domains on Windows with WampServer
Instead of working at http://localhost/myapp, you can give every project its own clean address like http://myapp.test. This guide explains the Windows hosts file and Apache virtual hosts, shows you how to wire them up, and how to add trusted HTTPS once they resolve.
Updated 30 May 2026
What is a local domain, and why use one?
A local domain is a hostname that resolves only on your own machine, such as myapp.test. Nothing about it is published to the internet; your computer simply agrees to treat that name as an address for itself.
Local domains are worth the small setup because they let you:
- Run each project at its own root (
myapp.test) instead of a sub-folder oflocalhost, so paths and cookies behave like production. - Run several projects side by side without path clashes.
- Match the domain your framework expects (Laravel, Symfony, WordPress multisite, and others care about the host).
- Add trusted HTTPS per domain, which a bare
localhostmakes awkward.
The Windows hosts file, explained
Before your computer asks a DNS server where a domain lives, it checks a local text file first. On Windows that file is:
C:\Windows\System32\drivers\etc\hosts
Any name you map there wins over the public internet. That is exactly what we want for local development: we point our chosen domain at 127.0.0.1, the address that always means “this machine”.
Step 1 — map the domain in the hosts file
Open Notepad as Administrator (the file is protected), open the hosts file above, and add a line:
127.0.0.1 myapp.test
Save it. To confirm the name now resolves to your machine, open a terminal and run:
ping myapp.test
You should see replies from 127.0.0.1. At this point the name resolves, but Apache does not yet know what to serve for it — that is the next step.
Step 2 — point Apache at it with a virtual host
A virtual host tells Apache which folder to serve for a given hostname. Open httpd-vhosts.conf in your WAMP install and add:
<VirtualHost *:80>
ServerName myapp.test
DocumentRoot "C:/wamp64/www/myapp/public"
<Directory "C:/wamp64/www/myapp/public">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
Restart the Apache (wampapache) service from the WampServer tray icon, then open http://myapp.test. Your project should load at its own clean address.
Tip: keep Require local so the vhost is only reachable from your own machine.
Why use .test, not .dev or .local?
Choose your suffix carefully:
- .test — reserved by the IETF for testing. It will never be a real public domain, so it is the safest choice.
- .dev — a real public top-level domain owned by Google, preloaded for HTTPS-only (HSTS). Using it locally causes confusing redirects. Avoid it.
- .local — reserved for multicast DNS (mDNS/Bonjour) and can clash with network discovery. Avoid it.
Stick with .test for predictable local development.
Step 3 — add trusted HTTPS
Once your domain resolves and Apache serves it, the last step is a trusted certificate so the browser shows a green padlock instead of a warning. That needs a local Certificate Authority and a correctly-profiled certificate — covered in detail in our guide to trusted HTTPS on WampServer.
You can do it by hand with OpenSSL, or let WAMP SSL Automator create the CA, issue the certificate, add the :443 vhost and hosts entry, restart Apache and verify the result — for every domain in your list, in one click.
Common problems and fixes
- The domain does not resolve. The hosts file was not saved as Administrator, or an antivirus locked it. Re-open Notepad elevated and save again; flush DNS with
ipconfig /flushdns. - You see the default WAMP page, not your project. The
DocumentRootpath is wrong, or Apache was not restarted after editing the vhost. - Apache will not start after editing vhosts. A syntax error in
httpd-vhosts.conf. Runhttpd -tto see the offending line, fix it, and restart. - 403 Forbidden. The
<Directory>block is missing or its path does not match theDocumentRoot.
FAQ
Where is the hosts file on Windows?
At C:\Windows\System32\drivers\etc\hosts. You must open your editor as Administrator to save changes, because the file is protected.
Do I need to edit the hosts file and an Apache vhost?
Yes — they do different jobs. The hosts file makes the domain resolve to your machine (127.0.0.1); the Apache virtual host tells the server which folder to serve for that domain.
Why should I use .test instead of .dev for local domains?
The .test suffix is reserved for testing and will never be a public domain. The .dev TLD is real and HTTPS-only (HSTS-preloaded), which causes confusing redirects when used locally.
How do I add HTTPS to a local domain?
Create a trusted local Certificate Authority, issue a certificate for the domain with a Subject Alternative Name, and add an Apache :443 vhost — or use WAMP SSL Automator to do all of it in one click.
Stop fighting certificate warnings.
Get trusted local HTTPS on your WAMP sites in one click — and get back to building.