วิธีทำ SEO Friendly URL สำหรับ SMF Forum (แบบ manual ง่ายๆ)

เริ่มโดย nistelbooy, 31 ตุลาคม 2009, 01:17:58

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

nistelbooy

วิธีทำ SEO Friendly URL สำหรับ SMF Forum สำหรับผู้ที่สนใจครับ (thanks)

อธิบายคร่าวๆ ดังนี้

เพิ่มไฟล์ .htaccess ไว้ใน root dir ใส่โค้ด

RewriteEngine On
RewriteBase /smf/

RewriteRule ^(.*)/(.*).html index.php?name=$1&board=$2
RewriteRule ^(.*)/(.*)/(.*).html index.php?board=$1&name=$2&topic=$3


ใน
Themes/default/BoardIndex.template.php และ
Themes/default/MessageIndex.template.php

#BoardIndex.template.php // หน้ารวมบอร์ด

ประมาณบรรทัดที่ 145 ตรง // ส่วนแสดงรายชื่อห้อง
<td class="windowbg2 info">

เพิ่มโค้ด

// mod rewrite
$urlweb = explode("/index.php",$scripturl);
$bid = $board['id'];
$name = $board['name'];
$array = array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","{","}","|","<",">","/","\\","\"","?",".");
foreach($array AS $string){
$name = str_replace($string,"",$name);
}
$name = str_replace(" ","-",$name);
$newurl = "$urlweb[0]/$name/$bid.html";
//echo '<h4><a href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a>'; //ของเดิม
echo '<h4><a href="', $newurl, '" name="b', $board['id'], '">', $board['name'], '</a>';


และประมาณบรรทัดที่ 310 ตรง // ส่วนแสดงรายชื่อกระทู้ล่าสุด
foreach ($context['latest_posts'] as $post){

เพิ่มโค้ด

// mod rewrite
$urlweb = explode("/index.php",$scripturl);
$urlweb = $urlweb[0];
$name = str_replace(" ","-",$post['subject']);
$bid = str_replace(" ","-",$post['board']['id']);
$bname = str_replace(" ","-",$post['board']['name']);
$tid = $post['topic'];
$array = array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","{","}","|","<",">","/","\\","\"","?",".");
foreach($array AS $string){
$name = str_replace($string,"",$name);
}
$name = str_replace(" ","-",$name);
$newurl = "$urlweb/$bname/$name/$tid.html";
$newurl = '<a href="'.$newurl.'">'.$post['subject'].'</a>';
$boardurl = "$urlweb/$bname/$bid.html";
$boardurl = '<a href="'.$boardurl.'">'.$post['board']['name'].'</a>';
//echo '<dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt><dd>', $post['time'], '</dd>'; // ของเดิม
echo '<dt><strong>', $newurl, '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $boardurl, ')</dt><dd>', $post['time'], '</dd>';



#MessageIndex.template.php // หน้ารวมกระทู้

และประมาณบรรทัดที่ 230 แถวๆ <td class="windowbg2 icon2">

เพิ่มโค้ด

// mod rewrite
$urlweb = explode("/index.php",$scripturl);
$bname = $_GET['name'];
$tid = $topic['id'];
$name = str_replace(" ","-",$topic['first_post']['subject']);
$array = array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","{","}","|","<",">","/","\\","\"","?",".");
foreach($array AS $string){
$name = str_replace($string,"",$name);
}
$name = str_replace(" ","-",$name);
$newurl = "$urlweb[0]/$bname/$name/$tid.html";
$newurl = '<a href="'.$newurl.'">'.$topic['first_post']['subject'].'</a>';
// $topic['first_post']['link']
//echo '<td class="subject ', $color_class, '" ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\');"' : ''), '>'; // ของเดิม
echo '<td class="subject ', $color_class, '" ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\');"' : ''), '>';


ลองดูนะครับ

ส่วน Themes อื่นๆ ก็เหมือนกัน เพียงแค่หาลิ้งเดิมให้เจอ

คิดว่าน่าจะมีประโยชน์กับเพื่อนๆนะครับ  :wanwan020:
งดรับงาน

nutthadej

รบกวนหน่อยครับ ถ้าอยากทำให้เวลาที่มี link out ออกจากบอร์ดให้เป็น nofollow ตลอดหรือให้ redirect แบบบอร์ดนี้ต้องไปแก้ตรงไหนครับ พอทราบไหมครับ
:wanwan008:
[direct=http://www.ns8.biz]Sublime Directory Services[/direct][direct=http://www.indexbargains.com/]Index Bargains Sublime Directory[/direct][direct=http://www.thecandydirectory.com/]The Candy Sublime Directory[/direct][direct=http://offerbestprice.com/]Best Buy Store[/direct][direct=http://bestbuystores.ws/]Best Buy Stores[/direct]

SazabiZ


bubbleball

รบกวนบอกผลลัพธ์ที่จะได้นิดนึงได้ไหมครับ

Nongkhai_tong

อ้างถึงจาก: nutthadej ใน 31 ตุลาคม 2009, 01:39:20
รบกวนหน่อยครับ ถ้าอยากทำให้เวลาที่มี link out ออกจากบอร์ดให้เป็น nofollow ตลอดหรือให้ redirect แบบบอร์ดนี้ต้องไปแก้ตรงไหนครับ พอทราบไหมครับ
:wanwan008:

กำลังอยากได้เหมือนกันคับแบบนี้มีใครช่วยได้บางน้อ

nistelbooy

ตัวอย่างครับ คร่าวๆ ไม่แน่ใจคนว่าคนอื่นมีวิธีไหนบ้างนะ (ผมไม่ได้ใช้ smf หรอก แต่อยากลองแต่งๆแก้ดู หุหุ)





งดรับงาน

ชงเข้ม

อ้างถึงจาก: Nongkhai_tong ใน 31 ตุลาคม 2009, 02:01:00
อ้างถึงจาก: nutthadej ใน 31 ตุลาคม 2009, 01:39:20
รบกวนหน่อยครับ ถ้าอยากทำให้เวลาที่มี link out ออกจากบอร์ดให้เป็น nofollow ตลอดหรือให้ redirect แบบบอร์ดนี้ต้องไปแก้ตรงไหนครับ พอทราบไหมครับ
:wanwan008:

กำลังอยากได้เหมือนกันคับแบบนี้มีใครช่วยได้บางน้อ

ดันครับ อยากรู้เหมือนกัน


i3enz


ก้ามปู

ตอนนี้ผมไม่ค่อยว่างตอบอะไรใครนะครับ เพราะไม่ได้เข้าบอร์ดเลย

civilclub

อ้างถึงจาก: nutthadej ใน 31 ตุลาคม 2009, 01:39:20
รบกวนหน่อยครับ ถ้าอยากทำให้เวลาที่มี link out ออกจากบอร์ดให้เป็น nofollow ตลอดหรือให้ redirect แบบบอร์ดนี้ต้องไปแก้ตรงไหนครับ พอทราบไหมครับ
:wanwan008:
นี่เลยครับ NoFollow All Links v1.1    hllp://custom.simplemachines.org/mods/index.php?mod=1236 ไม่ตามสักลิงค์  :wanwan007:

pongsak01

ทำไมผมทำไม่ได้หว่า ใครทำได้ ช่วยทีครับ

สเร็น


pongsak01

อ้างถึงจาก: nistelbooy ใน 31 ตุลาคม 2009, 01:17:58
วิธีทำ SEO Friendly URL สำหรับ SMF Forum สำหรับผู้ที่สนใจครับ (thanks)

อธิบายคร่าวๆ ดังนี้

เพิ่มไฟล์ .htaccess ไว้ใน root dir ใส่โค้ด

RewriteEngine On
RewriteBase /smf/

RewriteRule ^(.*)/(.*).html index.php?name=$1&board=$2
RewriteRule ^(.*)/(.*)/(.*).html index.php?board=$1&name=$2&topic=$3


ใน
Themes/default/BoardIndex.template.php และ
Themes/default/MessageIndex.template.php

#BoardIndex.template.php // หน้ารวมบอร์ด

ประมาณบรรทัดที่ 145 ตรง // ส่วนแสดงรายชื่อห้อง
<td class="windowbg2 info">

เพิ่มโค้ด

// mod rewrite
$urlweb = explode("/index.php",$scripturl);
$bid = $board['id'];
$name = $board['name'];
$array = array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","{","}","|","<",">","/","\\","\"","?",".");
foreach($array AS $string){
$name = str_replace($string,"",$name);
}
$name = str_replace(" ","-",$name);
$newurl = "$urlweb[0]/$name/$bid.html";
//echo '<h4><a href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a>'; //ของเดิม
echo '<h4><a href="', $newurl, '" name="b', $board['id'], '">', $board['name'], '</a>';


และประมาณบรรทัดที่ 310 ตรง // ส่วนแสดงรายชื่อกระทู้ล่าสุด
foreach ($context['latest_posts'] as $post){

เพิ่มโค้ด

// mod rewrite
$urlweb = explode("/index.php",$scripturl);
$urlweb = $urlweb[0];
$name = str_replace(" ","-",$post['subject']);
$bid = str_replace(" ","-",$post['board']['id']);
$bname = str_replace(" ","-",$post['board']['name']);
$tid = $post['topic'];
$array = array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","{","}","|","<",">","/","\\","\"","?",".");
foreach($array AS $string){
$name = str_replace($string,"",$name);
}
$name = str_replace(" ","-",$name);
$newurl = "$urlweb/$bname/$name/$tid.html";
$newurl = '<a href="'.$newurl.'">'.$post['subject'].'</a>';
$boardurl = "$urlweb/$bname/$bid.html";
$boardurl = '<a href="'.$boardurl.'">'.$post['board']['name'].'</a>';
//echo '<dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt><dd>', $post['time'], '</dd>'; // ของเดิม
echo '<dt><strong>', $newurl, '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $boardurl, ')</dt><dd>', $post['time'], '</dd>';



#MessageIndex.template.php // หน้ารวมกระทู้

และประมาณบรรทัดที่ 230 แถวๆ <td class="windowbg2 icon2">

เพิ่มโค้ด

// mod rewrite
$urlweb = explode("/index.php",$scripturl);
$bname = $_GET['name'];
$tid = $topic['id'];
$name = str_replace(" ","-",$topic['first_post']['subject']);
$array = array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","{","}","|","<",">","/","\\","\"","?",".");
foreach($array AS $string){
$name = str_replace($string,"",$name);
}
$name = str_replace(" ","-",$name);
$newurl = "$urlweb[0]/$bname/$name/$tid.html";
$newurl = '<a href="'.$newurl.'">'.$topic['first_post']['subject'].'</a>';
// $topic['first_post']['link']
//echo '<td class="subject ', $color_class, '" ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\');"' : ''), '>'; // ของเดิม
echo '<td class="subject ', $color_class, '" ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\', \'' . $context['session_id'] . '\');"' : ''), '>';


ลองดูนะครับ

ส่วน Themes อื่นๆ ก็เหมือนกัน เพียงแค่หาลิ้งเดิมให้เจอ

คิดว่าน่าจะมีประโยชน์กับเพื่อนๆนะครับ  :wanwan020:

ใครทำได้ pm มาครับ เสนอราคามาด้วยเด้อ พอดีผมมะเก่ง smf เหอะๆๆ

PIN

ทำไม่ได้อะครับ อยากทำได้มาก ๆ  คำว่า เพิ่มโค้ด หรือเพิ่มเข้าส่วนไหนนะครับ หรือเอาทับของเดิม หรือเพิ่มก่อนหน้า หรือเพิ่มต่อหลัง ครับ  พอดีลองทำ ๆ แล้ว มัน error นะคัรบ  รบกวนแนะนำด้วยครับ

nistelbooy

ยังไม่มีใครทำได้เลยหรอเนี่ย หุหุ

ไฟล์ .htaccess

RewriteEngine On
RewriteBase /smf/ <--- ชื่อโฟลเดอร์ ไม่มี ให้ใส่ /

RewriteRule ^(.*)/(.*).html index.php?name=$1&board=$2
RewriteRule ^(.*)/(.*)/(.*).html index.php?board=$1&name=$2&topic=$3

ไฟล์ Themes

http://www.tempf.com/getfile.php?id=202799&key=4aebae078ff1e
งดรับงาน

civilclub

แทงไป 1 ที  :wanwan002:
เข้าใจแล้วครับ ขอบคุณมากครับ เดี๋ยวไปลองทำก่อน ได้ผลอย่างไรจะมาบอกกันแบบละเอียดอีกครั้งครับ  :-[

nutthadej

อ้างถึงจาก: civilclub ใน 31 ตุลาคม 2009, 09:39:19
อ้างถึงจาก: nutthadej ใน 31 ตุลาคม 2009, 01:39:20
รบกวนหน่อยครับ ถ้าอยากทำให้เวลาที่มี link out ออกจากบอร์ดให้เป็น nofollow ตลอดหรือให้ redirect แบบบอร์ดนี้ต้องไปแก้ตรงไหนครับ พอทราบไหมครับ
:wanwan008:
นี่เลยครับ NoFollow All Links v1.1    hllp://custom.simplemachines.org/mods/index.php?mod=1236 ไม่ตามสักลิงค์  :wanwan007:

ขอบคุณหลายๆครับ และขอบคุณเจ้าของกระทู้ด้วยครับสำหรับความรู้ดีๆ
:wanwan017:
[direct=http://www.ns8.biz]Sublime Directory Services[/direct][direct=http://www.indexbargains.com/]Index Bargains Sublime Directory[/direct][direct=http://www.thecandydirectory.com/]The Candy Sublime Directory[/direct][direct=http://offerbestprice.com/]Best Buy Store[/direct][direct=http://bestbuystores.ws/]Best Buy Stores[/direct]

Twenty-One

# บริการโฮสติ้งขั้นเทพ 24/7 เปิดให้บริการ web hosting มาแล้ว 14 ปี ลูกค้ากว่า 40,000 ราย ให้ความไว้วางใจ
# [direct=https://www.hostneverdie.com]hosting[/direct] คุณภาพสูง ดูแลระบบโดย system engineer ประสบการณ์สูง
# [direct=https://www.hostneverdie.com]host[/direct] เร็ง แรง ไม่มีล่ม ติดตั้ง cms ฟรี
# [direct=https://www.hostneverdie.com/vps-server]vps[/direct] ราคาถูก 50GB 999 บาท

[direct=https://www.hostneverdie.com][/direct]

intel432

วิธีแบบนี้ จริงๆ ก็มีมานานแล้วละครับ มีคนพยายามลองแก้ในหลายๆ รูปแบบ ผลลัพธ์เป็นเหมือนที่เจ้าของกระทู้นำรูปมาให้ดู

แต่เวลาทาน Google มาดู แกแทบจะไม่สนใจเลยครับ เวลาแกเก็บข้อมูลกลับไปก็เป็นเหมือนเดิม

อันนี้เรื่องจริงครับ ผมพยายามทำ URL Friendly ของ SMF มาหลายทีแล้ว แต่ยังไม่มีวิธีไหนเวิร์คเลย

ลองดูนะครับ
[direct=http://www.gamegigs.com]ข่าวเกมส์ออนไลน์[/direct] ติดตามข่าวสารเกมส์ออนไลน์ อัพเดตตลอด 24 ชั่วโมง เล่นให้เก่งต้องมีคู่มือดีๆ [direct=http://www.gamegigs.com]Game Online[/direct] ใหม่ปี 2015 จะมีอะไรบ้างต้องติดตาม [direct=http://www.all2bot.com]บอท[/direct] ดาวน์โหลดโปรแกรมฟรีมากมาย [direct=http://shop.online-station.net]True Money[/direct] [direct=http://www.downloadhunt.com]โปรแกรม[/direct]