Look for httpd.conf
and add the following line at the bottom:
IncludeOptional "c:/amp/vhosts/*"
Now, go to c:/amp/vhosts
and create a file named vhosts.conf
.
> cd c:/amp/vhosts
> cd. > vhosts.conf
Open vhosts.conf
in a text editor then add in the following virtual hosts.
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:\\amp\\www"
</VirtualHost>
<VirtualHost *:80>
ServerName example.com.local
DocumentRoot "C:\\Path\\to\\project\\public\\directory"
<Directory />
AllowOverride all
Require all granted
</Directory>
# Redirect all http requests to its https counterpart
Redirect permanent / https://example.com.local/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com.local
DocumentRoot "C:\\Path\\to\\project\\public\\directory"
<Directory />
AllowOverride all
Require all granted
</Directory>
# Enables HTTPS
SSLEngine on
SSLCertificateFile "C:\\Path\\to\\public\\key"
SSLCertificateKeyFile "C:\\Path\\to\\private\\key"
</VirtualHost>
Also, add in the website domain to the hosts file (C:\Windows\System32\drivers\etc\hosts
). Note that modifying this file requires admin rights.
> cd "C:\Windows\System32\drivers\etc"
> notepad hosts
Add in the following line:
127.0.0.1 example.com.local
Finally, restart the Apache webserver and check example.com.local
in your browser. If using a self-signed certificate, the browser should intercept the request with a page saying something like "The site's security certificate is not trusted!". Proceed anyway, and done.