Tags:

เนื่องจากผมได้ลองติดตั้ง wordpress ไว้บน digitalocean แต่ผมมีปัญหาเกี่ยวกับ url ของแต่ละหน้าเป็นแบบนี้ครับ

www.[domainname].com/index.php/[page]

ซึ่งเมื่อก่อนตอนที่ใช้ shared host มันไม่มี index.php มาคั่นก่อนแบบนี้ ซึ่งผมได้ลองดูไฟล์ .htaccess เปรียบเทียบกันกับไฟล์ที่อยู่บน shared host ก็พบว่ามีรายละเอียดเหมือนกัน และในส่วนการตั้งค่าของ permalink ปัจจุบันเป็น /index.php/%postname/ เมื่อผมแก้เป็น /%postname/ ก็จะขึ้น error ว่า page not found

ดังนั้นเลยอยากขอคำแนะนำว่าปัญหาเกิดจากอะไร และต้องแก้ที่ตรงไหน รบกวนช่วยแนะนำด้วยครับ ขอบคุณครับ

edit: OS/Ubuntu 14.04 Webserver/Apache

.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Get latest news from Blognone
By: McKay
ContributorAndroidWindowsIn Love
on 21 March 2016 - 11:31 #895582
McKay's picture

ลองโพสโค๊ด .htaccess ๖รงส่วน mod_rewrite มาอ่ะครับ เผื่อจะมีคนช่วยได้


Russia is just nazi who accuse the others for being nazi.
someone once said : ผมก็ด่าของผมอยู่นะ :)

By: McKay
ContributorAndroidWindowsIn Love
on 21 March 2016 - 11:33 #895589 Reply to:895582
McKay's picture

OS/web server ด้วยนะครับ


Russia is just nazi who accuse the others for being nazi.
someone once said : ผมก็ด่าของผมอยู่นะ :)

By: nut_457
AndroidUbuntuWindows
on 21 March 2016 - 16:52 #895715

mod_rewrite อาจจะยังไม่ถูกโหลดเข้ามาครับ ลองตามนี้ดูก่อนครับ

sudo a2enmod rewrite
sudo service apache2 restart

By: gettary
ContributorAndroidUbuntuWindows
on 21 March 2016 - 17:26 #895746 Reply to:895715
gettary's picture

ลองแล้ว ก็ยังเหมือนเดิม ขอบคุณสำหรับคำแนะนำนะครับ

By: gettary
ContributorAndroidUbuntuWindows
on 21 March 2016 - 17:43 #895755 Reply to:895746
gettary's picture

ได้แล้วครับ หลังจากทำตามพบ error ในส่วนของการ restart server อ่าน อันนี้ โดยให้เข้าไปแก้ไฟล์ /etc/apache2/apache2.conf

แล้วเพิ่ม ServerName localhost

จากนั้นก็สามารถ restart server ได้ และปัญหาก็หายไปครับ