pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

HOW TO CONFIGURE VIRTUALHOSTS WITH APACHE IN WINDOWS (IN 2 STEPS)

When working with Apache on Windows, the most usual is to use WampServer or Xampp.

These “packages” allow us to install Apache, MySQL and PHP in a single pass.

And the result is as follows:

Our projects will be saved in a certain folder (usually wwww in Wamp and htdocs folder of Xamp).
We can access our projects by visiting the local host.
What we are going to configure now will allow us to access our projects from different directions.

This is very useful for Laravel projects, because it allows us to access our projects using my-project.localhost instead of localhost/my-project/public (this way we can avoid the use of php artisan serv and use Apache as server).

Configuration in 2 steps
The configuration that we are going to make consists of 2 steps.

First we are going to tell our operating system that when looking for the address localhost subdirectory of the folder, resolve this request through our local server (and do not search this page publicly on the Internet, as normally happens).

Then we’ll tell Apache how to resolve an incoming request for my-project.localhost (since Apache usually doesn’t know how to react to it).
File hosts and Virtual hosts
I know you’re eager to do the setup now.

As the title of the article says, it’s simply 2 steps.

If you’re in a hurry, you can skip this section. However, I recommend you continue reading.

Step 1

Hosts file

Every operating system presents a hosts file, to save the correspondence between Internet domains and IP addresses.
The location of this file depends on the operating system.
We will modify this file in step 1.
Virtual hosts

The creation of virtual hosts (or VirtualHosts) allows the same computer to resolve multiple domain names.
In our case we are going to tell Apache to resolve certain addresses through our local IP.
We will do this in step 2.
VirtualHosts are useful in different scenarios.

In this case, we will use them to configure our local development environment.

Well, let’s get started.

On Windows, the hosts file is located at hosts subdirectory within the drivers folder in System32.

This file allows us to map host names with IP addresses.

A default hosts file usually includes only the following definition:

Here you can add as many addresses as you need. I’ll give you an example for now.

I’m currently developing an application that will probably be available from tawa.com.pe. Locally I can use localhost of tawa.

The important thing is to use a domain name that doesn’t exist (and can’t exist in the future) in order to avoid collisions.


Step 2


If so far I access tawa.dev.pe from the browser, Apache will resolve this as if it were localhost.

This is because we have not yet created a VirtualHost to serve this address. Let’s get on with it.

Apache has a configuration file. You must open this file.

In the case of Wamp it is located in the httpd.conf subdirectory of the apache2.4.23 folder. (if you’re looking at this article from the future, the version might change)
We can create Virtual hosts directly on this file. But not. Apache usually includes other configuration files on top of this main file to keep an order.

Within this file we find the following lines:

Virtual hosts

Include the httpd-vhosts.conf file extension in your window. This is necessary to make the local hosts virtual declaration.

This will help you get the virtual host up and running. The process is very straightforward, so you shouldn’t have to dedicate too much time to it.

Filed Under: Articles

Latest Articles

18 Cool Pictures of Vintage Computers

In an era where sleek, high-performance devices have become our daily companions, it's both nostalgic and enlightening to take a step back in time and revisit the birth of the digital age. In this blog post, we're delving into the world of vintage computers, where computing power was measured in … [Read More...]

BIOS Settings

As soon as POST starts, you'll be invited to hit a key - generally DEL - to enterBIOS Setup. You've already set the system time, but now's the time to go through the various functions in detail and make sure they're set up in accordance with your motherboard User's Manual. Go through each … [Read More...]

Browser Hijacker: The I-beta.com Virus

The I-beta.com virus belongs to the classification of browser hijacker which is generally distributed by means of online free downloads. At first, it may look like it is helpful during search activities and works like the authentic program because it claims to be powered by Google. Nevertheless, in … [Read More...]

Gaming Laptop Security Guide: Protecting Your High-End Hardware Investment in 2025

Since Jacob took over PC Tech Guide, we’ve looked at how tech intersects with personal well-being and digital safety. Gaming laptops are now … [Read More...]

20 Cool Creative Commons Photographs About the Future of AI

AI technology is starting to have a huge impact on our lives. The market value for AI is estimated to have been worth $279.22 billion in 2024 and it … [Read More...]

13 Impressive Stats on the Future of AI

AI technology is starting to become much more important in our everyday lives. Many businesses are using it as well. While he has created a lot of … [Read More...]

Graphic Designers on Reddit Share their Views of AI

There are clearly a lot of positive things about AI. However, it is not a good thing for everyone. One of the things that many people are worried … [Read More...]

Redditors Talk About the Impact of AI on Freelance Writers

AI technology has had a huge impact on our lives. A 2023 survey by Pew Research found that 56% of people use AI at least once a day or once a week. … [Read More...]

11 Most Popular Books on Perl Programming

Perl is not the most popular programming language. It has only one million users, compared to 12 million that use Python. However, it has a lot of … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

10 Tips To Keep Your Computer Safe From Hackers And Viruses

There`s a never-ending flow of sophisticated scams and they come in many different disguises, that even the most IT savvy people can get caught in the … [Read More...]

Fight the Search Protect Invasion by Conduit

When it comes of web surfing, browser extension is believed to have malicious characteristics. Many users observed this to be true these past years … [Read More...]

The Role of Responsive Design in Modern Web Development

Responsive web design is becoming more essential with each passing day. Seventy-one percent of web developers believe the biggest reason users leave a … [Read More...]

[footer_backtotop]

Copyright © 2025 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors