Clean URLs

18 04 2008

ในตัวของ Drupal จะมี Clean URLs เป็นตัวช่วยเปลี่ยน URL ให้ดูดีขึ้น จาก localhost/drupal/?q=admin -> localhost/drupal/admin

ซึ่งการจะใช้งานขั้นแรกต้องไปทำการแก้ไขไฟล์ httpd.conf ก่อน

ซึ่งสิ่งที่เราต้องแก้คือ

ตรวจสอบว่าได้ติดต่อกับ Module ของ rewrite แล้วหรือยังโดยดูที่

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

ซึ่งถ้าไม่มีก็ใส่เพิ่ม (ถ้าไม่มี Module นี้ก็ต้องหามาลงเพิ่ม)

หลังจากนั้นก็ไปแก้ที่

<Directory />

Options FollowSymLinks

AllowOverride None

Order deny,allow

Deny from all

</Directory>

ให้เป็น

<Directory />

Options FollowSymLinks

AllowOverride All

Order deny,allow

Deny from all

</Directory>

และ

<Directory “/Library/WebServer/Documents”>

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

เป็น

<Directory “/Library/WebServer/Documents”>

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Order allow,deny

Allow from all

</Directory>

ทำการ Restart Apache แล้วเข้าไปที่ Drupal -> site configuration -> Clean URLs

ขั้นแรกเราต้องทำการ Test ก่อนโดยคลิกที่ Link Run the clean URL test

เมื่อ Test ผ่านก็ทำการ Enable แล้ว Save ก็จะไม่ต้องต้องใช้ ?q= ใน URL อีกต่อไป


เลือกคำสั่ง

ข้อมูล

ใส่ความเห็น