PukiWikiModで静的URL*1のSEO効果*2はひしひしと感じているので、フォーラム(newbb)にも静的URLを取り入れてみた。
newbb のディレクトリに以下の内容の .htaccess を置く
RewriteEngine on RewriteRule ^(viewforum|viewtopic|index)/(.*)$ /xoops/modules/newbb/$1.php?$2
各 .php で、PATH_INFO を使いパラメータを得る。
if(!empty($_SERVER["PATH_INFO"]) && preg_match("/^\/(.*)\/$/",$_SERVER["PATH_INFO"],$match))
{
$val = explode("/",$match[1]);
for($i=1;$i<=count($val);$i=$i+2)
{
if (!empty($val[$i-1]) && !empty($val[$i]))
$HTTP_GET_VARS[$val[$i-1]]=$_GET[$val[$i-1]] = $val[$i];
}
}
あとは、いろんなところで指定されているリンクを適宜書き換えてやればOK
とりあえず、XOOPS 2.0.7 の newbb と、このサイトの newbb の DIFF です。
部分的にこの件とは関係ない改造も含まれていますが、適当に読んでください。
また、この他にテンプレートも相対URLの部分を絶対URLに書き換える必要があります。
diff -crN xoops207/modules/newbb/.htaccess xoops/modules/newbb/.htaccess
*** xoops207/modules/newbb/.htaccess Thu Jan 01 09:00:00 1970
--- xoops/modules/newbb/.htaccess Mon Oct 25 09:14:06 2004
***************
*** 0 ****
--- 1,4 ----
+ RewriteEngine on
+ #RewriteRule ^(.+)\.php/(([^/]+)/([^/]+))?(/([^/]+)/([^/]+))?(/([^/]+)/([^/]+))?(/([^/]+)/([^/]+))?/([^/]*)$ /xoops/modules/newbb/$1.php?$3=$4&$6=$7&$9=$10&$12=$13$14
+ RewriteRule ^(viewforum|viewtopic|index)/(.*)$ /xoops/modules/newbb/$1.php?$2
+
diff -crN xoops207/modules/newbb/functions.php xoops/modules/newbb/functions.php
*** xoops207/modules/newbb/functions.php Sun Aug 22 12:54:26 2004
--- xoops/modules/newbb/functions.php Wed Oct 20 15:19:36 2004
***************
*** 198,204 ****
{
global $xoopsDB;
$myts = MyTextSanitizer::getInstance();
! $box = '<form action="viewforum.php" method="get">
<select name="forum">
';
$sql = 'SELECT cat_id, cat_title FROM '.$xoopsDB->prefix('bb_categories').' ORDER BY cat_order';
--- 198,204 ----
{
global $xoopsDB;
$myts = MyTextSanitizer::getInstance();
! $box = '<form action="'.XOOPS_URL.'/modules/newbb/viewforum.php" method="get">
<select name="forum">
';
$sql = 'SELECT cat_id, cat_title FROM '.$xoopsDB->prefix('bb_categories').' ORDER BY cat_order';
diff -crN xoops207/modules/newbb/index.php xoops/modules/newbb/index.php
*** xoops207/modules/newbb/index.php Sun Aug 22 12:54:26 2004
--- xoops/modules/newbb/index.php Wed Oct 27 22:53:20 2004
***************
*** 29,34 ****
--- 29,44 ----
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
+ if(!empty($_SERVER["PATH_INFO"]) && preg_match("/^\/(.*)\/$/",$_SERVER["PATH_INFO"],$match))
+ {
+ $val = explode("/",$match[1]);
+ for($i=1;$i<=count($val);$i=$i+2)
+ {
+ if (!empty($val[$i-1]) && !empty($val[$i]))
+ $HTTP_GET_VARS[$val[$i-1]]=$_GET[$val[$i-1]] = $val[$i];
+ }
+ }
+
include "header.php";
// this page uses smarty template
// this must be set before including main header.php
diff -crN xoops207/modules/newbb/viewforum.php xoops/modules/newbb/viewforum.php
*** xoops207/modules/newbb/viewforum.php Sun Aug 22 12:54:26 2004
--- xoops/modules/newbb/viewforum.php Wed Oct 27 22:51:03 2004
***************
*** 29,48 ****
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
include "header.php";
$forum = intval($HTTP_GET_VARS['forum']);
if ( $forum < 1 ) {
! redirect_header("index.php", 2, _MD_ERRORFORUM);
exit();
}
$sql = 'SELECT forum_type, forum_name, forum_access, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page FROM '.$xoopsDB->prefix('bb_forums').' WHERE forum_id = '.$forum;
if ( !$result = $xoopsDB->query($sql) ) {
! redirect_header("index.php", 2, _MD_ERRORCONNECT);
exit();
}
if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
! redirect_header("index.php", 2, _MD_ERROREXIST);
exit();
}
// this page uses smarty template
--- 29,61 ----
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
+ if(!empty($_SERVER["PATH_INFO"]) && preg_match("/^\/(.*)\/$/",$_SERVER["PATH_INFO"],$match))
+ {
+ $val = explode("/",$match[1]);
+ for($i=1;$i<=count($val);$i=$i+2)
+ {
+ if (!empty($val[$i-1]) && !empty($val[$i]))
+ $HTTP_GET_VARS[$val[$i-1]]=$_GET[$val[$i-1]] = $val[$i];
+ }
+ }
+
include "header.php";
$forum = intval($HTTP_GET_VARS['forum']);
if ( $forum < 1 ) {
! //redirect_header("index.php", 2, _MD_ERRORFORUM);
! redirect_header($bbUrl['root'], 2, _MD_ERRORFORUM);
exit();
}
$sql = 'SELECT forum_type, forum_name, forum_access, allow_html, allow_sig, posts_per_page, hot_threshold, topics_per_page FROM '.$xoopsDB->prefix('bb_forums').' WHERE forum_id = '.$forum;
if ( !$result = $xoopsDB->query($sql) ) {
! //redirect_header("index.php", 2, _MD_ERRORCONNECT);
! redirect_header($bbUrl['root'], 2, _MD_ERRORCONNECT);
exit();
}
if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
! //redirect_header("index.php", 2, _MD_ERROREXIST);
! redirect_header($bbUrl['root'], 2, _MD_ERROREXIST);
exit();
}
// this page uses smarty template
***************
*** 65,71 ****
$accesserror = 1;
}
if ( $accesserror == 1 ) {
! redirect_header("index.php",2,_MD_NORIGHTTOACCESS);
exit();
}
$can_post = 1;
--- 78,85 ----
$accesserror = 1;
}
if ( $accesserror == 1 ) {
! //redirect_header("index.php",2,_MD_NORIGHTTOACCESS);
! redirect_header($bbUrl['root'],2,_MD_NORIGHTTOACCESS);
exit();
}
$can_post = 1;
***************
*** 108,114 ****
$xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']));
$xoopsTpl->assign('forum_image_folder', $bbImage['folder_topic']);
$myts =& MyTextSanitizer::getInstance();
! $xoopsTpl->assign('forum_name', $myts->makeTboxData4Show($forumdata['forum_name']));
$xoopsTpl->assign('lang_moderatedby', _MD_MODERATEDBY);
$forum_moderators = "";
--- 122,132 ----
$xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX,$xoopsConfig['sitename']));
$xoopsTpl->assign('forum_image_folder', $bbImage['folder_topic']);
$myts =& MyTextSanitizer::getInstance();
! //nao-pon
! $forumdata['forum_name'] = $myts->makeTboxData4Show($forumdata['forum_name']);
! $xoopsTpl->assign("xoops_pagetitle",$forumdata['forum_name']."-"._MD_FORUM);
! $xoopsTpl->assign('forum_name', $forumdata['forum_name']);
! //$xoopsTpl->assign('forum_name', $myts->makeTboxData4Show($forumdata['forum_name']));
$xoopsTpl->assign('lang_moderatedby', _MD_MODERATEDBY);
$forum_moderators = "";
***************
*** 153,159 ****
// assign to template
$xoopsTpl->assign('forum_selection_order', $forum_selection_order);
! $sortsince = !empty($HTTP_GET_VARS['sortsince']) ? intval($HTTP_GET_VARS['sortsince']) : 100;
$sel_since_array = array(1, 2, 5, 10, 20, 30, 40, 60, 75, 100);
$forum_selection_since = '<select name="sortsince">';
foreach ($sel_since_array as $sort_since_v) {
--- 171,179 ----
// assign to template
$xoopsTpl->assign('forum_selection_order', $forum_selection_order);
! //nao-pon
! $sortsince = !empty($HTTP_GET_VARS['sortsince']) ? intval($HTTP_GET_VARS['sortsince']) : 1000;
! //$sortsince = !empty($HTTP_GET_VARS['sortsince']) ? intval($HTTP_GET_VARS['sortsince']) : 100;
$sel_since_array = array(1, 2, 5, 10, 20, 30, 40, 60, 75, 100);
$forum_selection_since = '<select name="sortsince">';
foreach ($sel_since_array as $sort_since_v) {
***************
*** 182,193 ****
$xoopsTpl->assign('h_date_link', "viewforum.php?forum=$forum&sortname=p.post_time&sortsince=$sortsince&sortorder=". (($sortname == "p.post_time" && $sortorder == "DESC") ? "ASC" : "DESC"));
$xoopsTpl->assign('lang_date', _MD_DATE);
! $startdate = time() - (86400* $sortsince);
$start = !empty($HTTP_GET_VARS['start']) ? intval($HTTP_GET_VARS['start']) : 0;
$sql = 'SELECT t.*, u.uname, u2.uname as last_poster, p.post_time as last_post_time, p.icon FROM '.$xoopsDB->prefix("bb_topics").' t LEFT JOIN '.$xoopsDB->prefix('users').' u ON u.uid = t.topic_poster LEFT JOIN '.$xoopsDB->prefix('bb_posts').' p ON p.post_id = t.topic_last_post_id LEFT JOIN '.$xoopsDB->prefix('users').' u2 ON u2.uid = p.uid WHERE t.forum_id = '.$forum.' AND (p.post_time > '.$startdate.' OR t.topic_sticky=1) ORDER BY topic_sticky DESC, '.$sortname.' '.$sortorder;
if ( !$result = $xoopsDB->query($sql,$forumdata['topics_per_page'],$start) ) {
! redirect_header('index.php',2,_MD_ERROROCCURED);
exit();
}
--- 202,216 ----
$xoopsTpl->assign('h_date_link', "viewforum.php?forum=$forum&sortname=p.post_time&sortsince=$sortsince&sortorder=". (($sortname == "p.post_time" && $sortorder == "DESC") ? "ASC" : "DESC"));
$xoopsTpl->assign('lang_date', _MD_DATE);
! //nao-pon
! $startdate = ($sortsince == 1000)? 0 : time() - (86400* $sortsince);
! //$startdate = time() - (86400* $sortsince);
$start = !empty($HTTP_GET_VARS['start']) ? intval($HTTP_GET_VARS['start']) : 0;
$sql = 'SELECT t.*, u.uname, u2.uname as last_poster, p.post_time as last_post_time, p.icon FROM '.$xoopsDB->prefix("bb_topics").' t LEFT JOIN '.$xoopsDB->prefix('users').' u ON u.uid = t.topic_poster LEFT JOIN '.$xoopsDB->prefix('bb_posts').' p ON p.post_id = t.topic_last_post_id LEFT JOIN '.$xoopsDB->prefix('users').' u2 ON u2.uid = p.uid WHERE t.forum_id = '.$forum.' AND (p.post_time > '.$startdate.' OR t.topic_sticky=1) ORDER BY topic_sticky DESC, '.$sortname.' '.$sortorder;
if ( !$result = $xoopsDB->query($sql,$forumdata['topics_per_page'],$start) ) {
! //redirect_header('index.php',2,_MD_ERROROCCURED);
! redirect_header($bbUrl['root'],2,_MD_ERROROCCURED);
exit();
}
***************
*** 219,225 ****
}
$pagination = '';
$addlink = '';
! $topiclink = 'viewtopic.php?topic_id='.$myrow['topic_id'].'&forum='.$forum;
$totalpages = ceil(($myrow['topic_replies'] + 1) / $forumdata['posts_per_page']);
if ( $totalpages > 1 ) {
$pagination .= ' <img src="'.XOOPS_URL.'/images/icons/posticon.gif" /> ';
--- 242,249 ----
}
$pagination = '';
$addlink = '';
! //$topiclink = 'viewtopic.php?topic_id='.$myrow['topic_id'].'&forum='.$forum;
! $topiclink = 'viewtopic/topic_id/'.$myrow['topic_id'].'/forum/'.$forum.'/';
$totalpages = ceil(($myrow['topic_replies'] + 1) / $forumdata['posts_per_page']);
if ( $totalpages > 1 ) {
$pagination .= ' <img src="'.XOOPS_URL.'/images/icons/posticon.gif" /> ';
***************
*** 228,235 ****
if ( $i > 3 && $i < $totalpages ) {
$pagination .= "...";
} else {
! $addlink = '&start='.(($i - 1) * $forumdata['posts_per_page']);
! $pagination .= '[<a href="'.$topiclink.$addlink.'">'.$i.'</a>]';
}
}
}
--- 252,260 ----
if ( $i > 3 && $i < $totalpages ) {
$pagination .= "...";
} else {
! //$addlink = '&start='.(($i - 1) * $forumdata['posts_per_page']);
! $addlink = 'start/'.(($i - 1) * $forumdata['posts_per_page']).'/';
! $pagination .= '[<a href="'.$bbUrl['root'].$topiclink.$addlink.'">'.$i.'</a>]';
}
}
}
diff -crN xoops207/modules/newbb/viewtopic.php xoops/modules/newbb/viewtopic.php
*** xoops207/modules/newbb/viewtopic.php Sun Aug 22 12:54:26 2004
--- xoops/modules/newbb/viewtopic.php Wed Oct 27 22:53:08 2004
***************
*** 29,42 ****
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
include 'header.php';
$forum = isset($HTTP_GET_VARS['forum']) ? intval($HTTP_GET_VARS['forum']) : 0;
$topic_id = isset($HTTP_GET_VARS['topic_id']) ? intval($HTTP_GET_VARS['topic_id']) : 0;
if ( empty($forum) ) {
! redirect_header('index.php',2,_MD_ERRORFORUM);
exit();
} elseif ( empty($topic_id) ) {
! redirect_header('viewforum.php?forum='.$forum,2,_MD_ERRORTOPIC);
exit();
}
$topic_time = (isset($HTTP_GET_VARS['topic_time'])) ? intval($HTTP_GET_VARS['topic_time']) : 0;
--- 29,52 ----
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
+ if(!empty($_SERVER["PATH_INFO"]) && preg_match("/^\/(.*)\/$/",$_SERVER["PATH_INFO"],$match))
+ {
+ $val = explode("/",$match[1]);
+ for($i=1;$i<=count($val);$i=$i+2)
+ {
+ if (!empty($val[$i-1]) && !empty($val[$i]))
+ $HTTP_GET_VARS[$val[$i-1]]=$_GET[$val[$i-1]] = $val[$i];
+ }
+ }
+
include 'header.php';
$forum = isset($HTTP_GET_VARS['forum']) ? intval($HTTP_GET_VARS['forum']) : 0;
$topic_id = isset($HTTP_GET_VARS['topic_id']) ? intval($HTTP_GET_VARS['topic_id']) : 0;
if ( empty($forum) ) {
! redirect_header($bbUrl['root'],2,_MD_ERRORFORUM);
exit();
} elseif ( empty($topic_id) ) {
! redirect_header($bbUrl['root'].'viewforum/forum/'.$forum,2,_MD_ERRORTOPIC);
exit();
}
$topic_time = (isset($HTTP_GET_VARS['topic_time'])) ? intval($HTTP_GET_VARS['topic_time']) : 0;
***************
*** 82,93 ****
}
if ( !$result = $xoopsDB->query($sql) ) {
! redirect_header('viewforum.php?forum='.$forum,2,_MD_ERROROCCURED);
exit();
}
if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
! redirect_header('viewforum.php?forum='.$forum,2,_MD_FORUMNOEXIST);
exit();
}
$xoopsTpl->assign('topic_id', $forumdata['topic_id']);
--- 92,103 ----
}
if ( !$result = $xoopsDB->query($sql) ) {
! redirect_header($bbUrl['root'].'viewforum/forum/'.$forum,2,_MD_ERROROCCURED);
exit();
}
if ( !$forumdata = $xoopsDB->fetchArray($result) ) {
! redirect_header($bbUrl['root'].'viewforum/forum/'.$forum.'/',2,_MD_FORUMNOEXIST);
exit();
}
$xoopsTpl->assign('topic_id', $forumdata['topic_id']);
***************
*** 111,117 ****
$accesserror = 1;
}
if ( $accesserror == 1 ) {
! redirect_header("index.php",2,_MD_NORIGHTTOACCESS);
exit();
}
$can_post = 1;
--- 121,127 ----
$accesserror = 1;
}
if ( $accesserror == 1 ) {
! redirect_header($bbUrl['root'],2,_MD_NORIGHTTOACCESS);
exit();
}
$can_post = 1;
***************
*** 140,146 ****
}
$myts =& MyTextSanitizer::getInstance();
$forumdata['topic_title'] = $myts->makeTboxData4Show($forumdata['topic_title']);$forumdata['forum_name'] = $myts->makeTboxData4Show($forumdata['forum_name']);
! $xoopsTpl->assign(array('topic_title' => '<a href="'.$bbUrl['root'].'viewtopic.php?viewmode='.$viewmode.'&topic_id='.$topic_id.'&forum='.$forum.'">'.$forumdata['topic_title'].'</a>', 'forum_name' => $forumdata['forum_name'], 'topic_time' => $forumdata['topic_time'], 'lang_nexttopic' => _MD_NEXTTOPIC, 'lang_prevtopic' => _MD_PREVTOPIC));
// add image links to admin page if the user viewing this page is a forum admin
if ( $xoopsUser ) {
--- 150,159 ----
}
$myts =& MyTextSanitizer::getInstance();
$forumdata['topic_title'] = $myts->makeTboxData4Show($forumdata['topic_title']);$forumdata['forum_name'] = $myts->makeTboxData4Show($forumdata['forum_name']);
! $xoopsTpl->assign(array('topic_title' => '<a href="'.$bbUrl['root'].'viewtopic/topic_id/'.$topic_id.'/forum/'.$forum.'/viewmode/'.$viewmode.'/">'.$forumdata['topic_title'].'</a>', 'forum_name' => $forumdata['forum_name'], 'topic_time' => $forumdata['topic_time'], 'lang_nexttopic' => _MD_NEXTTOPIC, 'lang_prevtopic' => _MD_PREVTOPIC));
!
! //nao-pon
! $xoopsTpl->assign("xoops_pagetitle",$forumdata['topic_title']."-".$forumdata['forum_name']."-"._MD_FORUM);
// add image links to admin page if the user viewing this page is a forum admin
if ( $xoopsUser ) {
***************
*** 205,211 ****
$post_image = '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
}
if ($current != $key) {
! $subject = '<a href="viewtopic.php?viewmode=thread&topic_id='.$arr[$key]['obj']->topic().'&forum='.$arr[$key]['obj']->forum().'&post_id='.$arr[$key]['obj']->postid().'#'.$arr[$key]['obj']->postid().'">'.$arr[$key]['obj']->subject().'</a>';
$GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $prefix)));
} else {
$subject = '<b>'.$arr[$key]['obj']->subject().'</b>';
--- 218,225 ----
$post_image = '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
}
if ($current != $key) {
! //$subject = '<a href="viewtopic.php?viewmode=thread&topic_id='.$arr[$key]['obj']->topic().'&forum='.$arr[$key]['obj']->forum().'&post_id='.$arr[$key]['obj']->postid().'#'.$arr[$key]['obj']->postid().'">'.$arr[$key]['obj']->subject().'</a>';
! $subject = '<a href="'.$bbUrl['root'].'viewtopic/viewmode/thread/topic_id/'.$arr[$key]['obj']->topic().'/forum/'.$arr[$key]['obj']->forum().'/post_id/'.$arr[$key]['obj']->postid().'/#'.$arr[$key]['obj']->postid().'">'.$arr[$key]['obj']->subject().'</a>';
$GLOBALS['xoopsTpl']->append("topic_trees", array_merge($posterarr, array("post_id" => $arr[$key]['obj']->postid(), "post_parent_id" => $arr[$key]['obj']->parent(), "post_date" => formatTimestamp($arr[$key]['obj']->posttime(), "m"), "post_image" => $post_image, "post_title" => $subject, "post_prefix" => $prefix)));
} else {
$subject = '<b>'.$arr[$key]['obj']->subject().'</b>';
***************
*** 242,248 ****
}
if ( $can_post == 1 ) {
! $xoopsTpl->assign(array('viewer_can_post' => true, 'forum_post_or_register' => "<a href=\"newtopic.php?forum=".$forum."\"><img src=\"".$bbImage['post']."\" alt=\""._MD_POSTNEW."\" /></a>"));
} else {
$xoopsTpl->assign('viewer_can_post', false);
if ( $show_reg == 1 ) {
--- 256,262 ----
}
if ( $can_post == 1 ) {
! $xoopsTpl->assign(array('viewer_can_post' => true, 'forum_post_or_register' => "<a href=\"{$bbUrl['root']}newtopic.php?forum=".$forum."\"><img src=\"".$bbImage['post']."\" alt=\""._MD_POSTNEW."\" /></a>"));
} else {
$xoopsTpl->assign('viewer_can_post', false);
if ( $show_reg == 1 ) {
しかし、自分ではいいと思っていても不具合はあるもの。なにか、おかしなところを発見したら、ぜひお知らせください。
お願いします
-- yshima 2004-10-26 (火) 11:47:52
-- nao-pon 2004-10-27 (水) 23:23:02
-- yshima 2004-10-26 (火) 11:54:11
| Page name: | 徒然日記/2004-10-25 [ Sended pings(0) ] | |
| Author: | nao-pon | - 2004/10/28 13:51:21 JST(2660d) |
| Last edit: | nao-pon | - 2004/10/28 13:51:21 JST(2660d) |
| Editers: | nao-pon | |
| Back Link: | NEWS(693d) PukiWikiMod(985d) nao-pon(1403d) .htaccess(1859d) XOOPS(2071d) nao-pon(2317d) 徒然日記(2729d) | |
ログイン
メインメニュー
Home
新着情報
フォーラム
UsersWiki
xpWiki::Dev
Wiki [自由帳]
Recent View
View List
書籍情報
価格比較の最安百貨
写メールBBS
たぐめも
ダウンロード
箱庭諸島
リンク集
カレンダー
お問い合わせ
サイトマップ
参照元情報
イメージマネージャ
|
最新のページ
ブックマーク
新着トラックバック
サイト内 Wiki
☆ 検索 ☆
オンライン状況
サイト情報
現在ページのQRコード
参照元情報