Indresh Verma
Step-by-step guide to set up a subdomain in localhost for your web development projects
In this tutorial, we will walk you through the steps to create a subdomain in localhost. You will learn how to configure Apache or Nginx web servers to serve your subdomain locally. This setup is useful for web development and testing before going live.
To make sure your system resolves the subdomain to your local machine, you'll need to modify the hosts file on your computer.
Add the following line to map the subdomain to your local machine:
127.0.0.1 subdomain.localhost
Save the file, and you're ready to proceed.
Next, you'll configure either Apache or Nginx to handle requests for your subdomain.
If you're using Apache, open the `httpd-vhosts.conf` file and add the following VirtualHost configuration:
<VirtualHost *:80>
ServerName subdomain.localhost
DocumentRoot "C:/path_to_your_project_folder"
<Directory "C:/path_to_your_project_folder">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Don't forget to restart Apache to apply the changes.
If you're using Nginx, edit the `nginx.conf` file or create a new server block in the `sites-available` directory:
server {
listen 80;
server_name subdomain.localhost;
root /path_to_your_project_folder;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
}
Restart Nginx to apply the changes.
Open your browser and navigate to subdomain.localhost. If everything is configured correctly, you should see your web page served from the specified directory.
If your subdomain isn't working, ensure the following:
Advanced Color Picker | Choose and Save Your Perfect Color Palette
Advanced and user-friendly color picker tool for web designers and developers. Choose, save, and explore color palettes and harmonies effortlessly.
Free JPG to PDF Converter - Convert JPG to PDF Online for Free
Convert JPG images to PDF online for free. No watermark, no registration. Fast, secure & easy to use. JPG to PDF, Image to PDF, PDF converter
How to Improve Cursor Speed and Boost Laptop Performance | Acer R3 131-T
Learn how to improve cursor speed and boost the performance of your Acer R3 131-T laptop with these simple steps. Optimize settings, upgrade hardware, and enhance your device today.