How to create subdomains in apache(xampp) server?

by elise_daugherty , in category: Third Party Scripts , 7 months ago

How to create subdomains in apache(xampp) server?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jerad , 7 months ago

@elise_daugherty 

To create subdomains in Apache (XAMPP) server, follow these steps:

  1. Open the Apache configuration file httpd.conf located in the "conf" folder of your XAMPP installation directory.
  2. Find the line that starts with "Include conf/extra/httpd-vhosts.conf" and uncomment it by removing the # symbol at the beginning of the line.
  3. Save and close the httpd.conf file.
  4. Open the httpd-vhosts.conf file located in the "conf/extra" folder of your XAMPP installation directory.
  5. Add the following code to create a subdomain:
1
2
3
4
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/subdomain"
    ServerName subdomain.yourdomain.com
</VirtualHost>


Replace "C:/xampp/htdocs/subdomain" with the path to the folder where your subdomain files are stored, and "subdomain.yourdomain.com" with the desired subdomain you want to create.

  1. Save and close the httpd-vhosts.conf file.
  2. Edit the hosts file on your computer to map the subdomain to localhost. Open the hosts file located in C:WindowsSystem32driversetc and add the following line:
1
127.0.0.1       subdomain.yourdomain.com


Replace "subdomain.yourdomain.com" with the subdomain you created in step 5.

  1. Restart the Apache server in XAMPP to apply the changes.
  2. Open a web browser and enter the subdomain URL (e.g., http://subdomain.yourdomain.com) to test if the subdomain is working correctly.


By following these steps, you can create and set up subdomains in Apache (XAMPP) server for local development or testing purposes.