หากโพสไม่ถูกหมวด ขออภัย ณ ที่นี้ด้วยครับ
เข้าเรื่องน่ะครับ
1. ก่อนหน้านี้ผม ใช้ Mac ที่ออฟฟิศ ในการพัฒนาเว็บและลง Xampp เพื่อจำลอง Server และผมเขียน htaccess ตาม code ด้านล่าง
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-zA-Z0-9_-]+)/(.*\.jpg|.*\.gif|.*\.css|.*\.js)$ $2 [L]
RewriteRule ^หน้าแรก\.html$ /index.php [NC,L]
RewriteRule ^รับสร้างบ้าน/แบบบ้าน\.html$ /allhouse.php [NC,L]
RewriteRule ^รับสร้างบ้าน/แบบบ้าน/ตามขนาดพื้นที่/(.*)\.html$ /allhouse.php?land_area=$1 [NC,L]
RewriteRule ^รับสร้างบ้าน/แบบบ้าน/ตามพื้นที่ใช้สอย/(.*)\.html$ /allhouse.php?living_area=$1 [NC,L]
RewriteRule ^รับสร้างบ้าน/แบบบ้าน/ตามดีไซน์/(.*)\.html$ /allhouse.php?h_style_id=$1 [NC,L]
RewriteRule ^รับสร้างบ้าน/แบบบ้าน/ตามงบประมาณ/(.*)\.html$ /allhouse.php?search=$1 [NC,L]
RewriteRule ^รับสร้างบ้าน/แบบบ้าน3ชั้น\.html$ /allhouse.php?search=6 [NC,L]
RewriteRule ^แปลนบ้าน-(.*)-(.*)\.html$ /house_view.php?search=$1&h_id=$2 [NC,L]
RewriteRule ^เกี่ยวกับเรา/(.*)/(.*)\.html$ /about.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^เปิดตำนาน/(.*)/(.*)\.html$ /about.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^คณะผู้บริหาร/(.*)/(.*)\.html$ /about.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^จุดเด่นของบริษัท/(.*)/(.*)\.html$ /about.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^สร้างบ้าน/ระบบเสา-คาน-สำเร็จรูป/(.*)/(.*)\.html$ /about.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^สร้างบ้าน/ระบบผนัง-สำเร็จรูป/(.*)/(.*)\.html$ /about.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^การคุบคุมคุณภาพ/(.*)/(.*)\.html$ /quality.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^ผลงานของเรา-page-(.*)\.html$ /portfolio_list.php?page=$1 [NC,L]
RewriteRule ^ผลงานของเรา-(.*)\.html$ /port_view.php?port_id=$1 [NC,L]
RewriteRule ^ผลงานของเรา\.html$ /portfolio_list.php [NC,L]
RewriteRule ^open-house-view-(.*)\.html$ /family_view.php?family_id=$1 [NC,L]
RewriteRule ^open-house-page-(.*)\.html$ /family.php?page=$1 [NC,L]
RewriteRule ^open-house\.html$ /family.php [NC,L]
RewriteRule ^เตรียมตัวสร้างบ้าน-(.*)-(.*)\.html$ /prepare.php?con_id_uniq=$1&con_type_id=$2 [NC,L]
RewriteRule ^ข่าวสารและกิจกรรม-(.*)-(.*)\.html$ /news.php?news_type_id=$1&page=$2 [NC,L]
RewriteRule ^ข่าวสารและกิจกรรม-(.*)\.html$ /news.php?news_type_id=$1 [NC,L]
RewriteRule ^รายละเอียด-(.*)\.html$ /news_view.php?news_type_id=$1 [NC,L]
RewriteRule ^รายละเอียด-(.*)-(.*)\.html$ /news_view.php?news_type_id=$1&news_id=$2 [NC,L]
RewriteRule ^Articles-(.*)-(.*)\.html$ /article.php?art_type_id=$1&page=$2 [NC,L]
RewriteRule ^Articles-(.*)\.html$ /article.php?art_type_id=$1 [NC,L]
RewriteRule ^Articles_views-(.*)-(.*)\.html$ /article_view.php?art_type_id=$1&art_id=$2 [NC,L]
ผลลัพธ์ก็ออกมาตามที่คาดไม่มีปัญหาอะไร
แต่เมื่อวันก่อน ออฟฟิศเปลี่ยนเครื่องใหม่ให้เป็น Notebook ของ Asus และได้ลง window 8.1 มาให้
ผมก็ทำการลง apperv 2.5.10 มาลง และเปิดโหมด rewrite ตามปกติที่เคยทำ แต่เกิดปัญหาดังนี้ครับ
ไฟล์ .htaccess ไม่สามารถใช้งานได้ โดยมันขึ้น "Internal Server Error"
แก้ปัญหาเบื้อต้น ผมลองลบเงื่อนไขออกเหลือแค่
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-zA-Z0-9_-]+)/(.*\.jpg|.*\.gif|.*\.css|.*\.js)$ $2 [L]
RewriteRule ^หน้าแรก\.html$ /index.php [NC,L]
ก็สามารถใช้งานได้
ผมเลยอยากเรียนถามพี่ๆ เพื่อนๆ ว่า มันเกิดจากสาเหตุอะไรหรือผมเขียนเงื่อนไขผิดตรงไหนหรือเปล่าครับ
(ปล. ทั้งนี้ ไฟล์ .htaccess นี้สามารถใช้ได้บน server จริงครับ)
Tag : - - - -