Skip to main content

Custom url domain in Xampp

If you are developing website in Xampp, you can use custom domain instead of localhost or You can make url like http://mydomain.local as an url for you local development.

Prepare project #

I'm assuming you have website project directory in C:/xampp/htdocs/mywebsite. We want to use url http://mydomain.local. I like using .local TLD to differentiate it with actual internet url. Then, add this line in the bottom.

Edit hosts file #

Open C:\Windows\System32\drivers\etc\hosts. You need Administrator Access to edit this file. mywebsite.local www.mywebsite.local

Edit httpd-vhosts.conf #

This file is located in C:\xampp\apache\conf\extra\httpd-vhosts.conf. Add this code to the bottom.

<VirtualHost *:80>
  DocumentRoot C:/xampp/htdocs/
  ServerName localhost

Then, add this code and adjust with your projects.

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/mywebsite"
    ServerName mywebsite.local
    ServerAlias www.mywebsite.local
    <Directory "C:/xampp/htdocs/mywebsite">
        AllowOverride All
        Require all granted

Finishing #

You are done. Start or restart your Apache server. Go to http://mywebsite.local to test it. If you have any problems, drop the comments below.