ประกาศ

เนื้อหาใน Wiki นี้ เป็นการรวบรวมข้อมูลเพื่อไว้ศึกษา สงวนลิขสิทธิ์ ห้ามนำไปใช้ในรูปแบบต่าง ๆ โดยที่ไม่ได้รับความยินยอมจาก ผู้ดูแลระบบ เว้นแต่เพื่อการศึกษาส่วนตัวเท่านั้น การเข้าใช้งาน ถือว่าเป็นการยอมรับเงื่อนไขนี้ โดยไม่มีข้อโต้แย้งใด ๆ ทั้งสิ้น

This is an old revision of the document!


การทำ virtual host

นี่เป็นตัวอย่างโค้ด การทำ virtual host ไฟล์ httpd-vhosts.conf

ในโค้ดด้านล่างจะมีอยู่ 4 ช่วงด้วยกัน

  1. ช่วงแรกและช่วงสุดท้าย เป็นโค้ดสำหรับทำ wildcard subdomain
  2. ช่วง 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

QR Code
QR Code wordpress:xampp-virtual-host (generated for current page)