1 127.0.0.1 blog.testing
Setelah itu silakan File->Save. File hosts harus diedit sebagai administrator, oleh
karena itu klik Yes ketika diminta mode sebagai Administrator dan akhiri sekali
lagi dengan mengklik File->Save atau Ctr+s untuk menyimpan perubahan tadi.
Edit File httpd-vhosts.conf
Silakan buka file httpd-vhosts.conf yang terletak
pada C:/xampp/apache/conf/extra/httpd-vhosts.conf. kemudian edit dan
tambahkan kode berikut:
1 <VirtualHost *:80>
2 ServerAdmin webmaster@localhost
3 DocumentRoot "E:/MyProject/blog/public"
4 ServerName blog.testing
5 ServerAlias blog.testing
6 ErrorLog "logs/blog.testing-error.log"
7 CustomLog "logs/blog.testing-access.log" common
8
9 <Directory "E:/MyProject/blog/public">
10 Options Indexes FollowSymLinks Includes ExecCGI
11 AllowOverride All
12 Require all granted
13 </Directory>
14
15 </VirtualHost>
Sesuaikan DocumentRoot dengan letak aplikasi pada PC. Pada contoh di atas
DocumentRoot terletak pada Drive E dengan folder /MyProject/blog/public.
Sekarang saatnya mengakses virtualhost tersebut. Silakan buka dengan url
http://blog.testing
Jika url localhost diakses yang muncul ternyata persis seperti blog.testing, maka
buatlah VirtualHost localhost dengan urutan paling atas, sehingga script
lengkapnya sebagai berikut:
1 <VirtualHost *:80>
2 ServerAdmin webmaster@localhost
3 DocumentRoot "C:/xampp/htdocs"
4 ServerName localhost
5 ServerAlias localhost
6 ErrorLog "logs/localhost-error.log"
7 CustomLog "logs/localhost-access.log" common
8
9 <Directory "C:/xampp/htdocs">
10 Options Indexes FollowSymLinks Includes ExecCGI
11 AllowOverride All
12 Require all granted
13 </Directory>
14 </VirtualHost>
15
16 <VirtualHost *:80>
17 ServerAdmin webmaster@localhost
18 DocumentRoot "E:/MyProject/blog/public"
19 ServerName blog.testing
20 ServerAlias blog.testing
21 ErrorLog "logs/blog.testing-error.log"
22 CustomLog "logs/blog.testing-access.log" common
23
24 <Directory "E:/MyProject/blog/public">
25 Options Indexes FollowSymLinks Includes ExecCGI
26 AllowOverride All
27 Require all granted
28 </Directory>
29
30 </VirtualHost>
v