This is an old revision of the document!
การทำ virtual host
นี่เป็นตัวอย่างโค้ด การทำ virtual host ไฟล์ httpd-vhosts.conf
ในโค้ดด้านล่างจะมีอยู่ 4 ช่วงด้วยกัน
- ช่วงแรกและช่วงสุดท้าย เป็นโค้ดสำหรับทำ wildcard subdomain
- ช่วง 2-3 เป็นช่วงของ domain และ sub domain แบบปกติ คือ localhost และ wordpress.localhost
การวางโค้ดสำหรับ wildcard sub domain ควรวางหลัง virtual host
UseCanonicalName Off
<VirtualHost *:80> DocumentRoot "C:\xampp\htdocs" ServerName localhost <Directory "C:\xampp\htdocs"> Options Indexes Require all granted </Directory> </VirtualHost>
<VirtualHost *:80> DocumentRoot "C:\web\htdocs" ServerName wordpress.localhost <Directory "C:\web\htdocs"> Options Indexes Require all granted </Directory> </VirtualHost>
<VirtualHost *:80> ServerAlias *.localhost VirtualDocumentRoot "C:/xampp/htdocs/%1/" </VirtualHost>
ในส่วน <Directory> อาจจะใส่โค้ดแบบด้านล่างนี้ก็ได้
Options FollowSymLinks Indexes AllowOverride All Order deny,allow allow from All