Magento 2 On Localhost , In this tutorials i am going to show you how to setup virtual hosts for Magento 2 websites with XAMPP running on windows
There are 3 steps to setup Magento 2 on localhost you have to follow
1.) Add vitual host configuration in D:\xampp\apache\conf\extra\httpd-vhosts file . location of file depends on where you have installed xampp .
open httpd-vhosts file , add below code and replace yourdomainname and project directory with yours.finally save the file.
ServerAdmin youremail@yourdomainname.com
DocumentRoot "D:/xampp/htdocs/Projectname/pub"
ServerName yourdomainname.com
ServerAlias www.yourdomainname.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
2.) In this step you have to add the yourdomain name in hosts file located at C:\Windows\System32\drivers\etc\hosts .
open file in editor with Administrative Privileges , add below line and save it.
127.0.0.1 yourdomainname.com
3.) Please restart apache using XAMPP control panel and update the base url in core_config_data table to your new setup vitualhost.