PHP版Yomi-Searchを静的化する
PHP版のYomi-Searchのカテゴリのリンクログの表示方法はHTMLを書き出すタイプではなく、接続の度にデータベースからデータを呼び出し、動的に構成しています。
よって、PHP版Yomi-Searchを静的化するためにはmod_rewriteを利用して行います。
下記に解説している変更済みのファイルのみ必要な場合はダウンロードしてください。
アップロード後環境設定変更を行っていただければPHP版Yomi-Search静的化完了です。
ご自身でカスタマイズされたい方は、下記の詳細をお読みください。
mod_rewrite設定
まず.htaccessにmod_rewriteの記述をしてあげます。
.htaccessファイルを作成し、下記を記述
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#ディレクトリ
RewriteRule ^([0-9]+)/$ index.php?mode=dir&path=$1/
RewriteRule ^([0-9]+)/([0-9]+)/$ index.php?mode=dir&path=$1/$2/
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/$ index.php?mode=dir&path=$1/$2/$3/
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+).html$ index.php?page=$3&mode=dir&path=$1/$2/&sort=
.htaccessを記述したらRewriteEngineが正常に動いているか確かめてみます。
下記のURLにアクセスしてみてください。
http://貴方のドメイン/カテゴリ名(01や01/01)/
この段階できちんと表示されていれば、あとは、プログラムのURL出力を変更するだけです。
もし、表示されていなければ、サーバー事態が.htaccessに対応していなかったり、mod_rewriteが組み込まれていない可能性があります。
詳しくは各サーバー管理者にお尋ねください。
なお、Yomi-Search自体をサーバーの特定フォルダ内にインストールしている方は、 RewriteBaseのパスを書き直すか、記述を削除して確認してみてください。
環境設定の変更
管理画面よりログインして、「環境設定」→「yomi.phpのファイル名」を見てください。
デフォルトではyomi.phpとなっておりますが、ここを空にしてください。
また、その下にある「検索用のCGIファイル名」「ランキング用のCGIファイル名」「管理処理用のCGIファイル名」を絶対パスのURLに書き換えてください。
例 search.php → http://貴方のドメイン/search.php
そして、同じく「環境設定」一番下にある「メニューバー/外部検索エンジン/ヘッダ・フッタスペースの設定 」の 「1.メニューバーの設定」をすべてURL付の絶対パスに変更してください。
<a href="http://貴方のドメイン/yomi.php?mode=new">新着サイト</a> -
<a href="http://貴方のドメイン/yomi.php?mode=renew">更新サイト</a> -
<a href="http://貴方のドメイン/rank.php">人気ランキング</a> -
<a href="http://貴方のドメイン/rank.php?mode=keyrank">キーワードランキング</a> -
<a href="http://貴方のドメイン/yomi.php?mode=m1">おすすめサイト</a> -
<a href="http://貴方のドメイン/yomi.php?mode=m2">相互リンクサイト</a>
テンプレートの変更
次にテンプレートやプログラムファイル内を修正して、サイト内リンクの吐き出しをすべて静的URLに書き換えます。
作業は必ずバックアップを取ってから行ってください
(青追加、赤削除)
template/category.htmlの各行追加
8行目
<link rel="stylesheet" href="<?=$cfg[home]?>style.css" type="text/css">
88行目
[<a href="<?=$cfg[home]?>sitemap.php">サイトマップ</a>]
template/top.htmlの各行を削除
86行目
<td width="50%"><a href="<?=$cfg['script']."?mode=dir&path=".$row[path]?>"><b><font size="+1"><?=$row['title']?></font></b></a><br>
96行目
echo "\n<font id=small><a href=\"$cfg[script]?mode=dir&path=$row[path]\">$row[title]</a></font>, ";
100行目
echo "<a href=\"$cfg[script]?mode=dir&path=$top_path\">...</a>";
functions.php各行すべて変更
54行目
echo "<td>■<a href=\"$cfg[script]?mode=dir&path=$row[path]\">".$row[title]."</a></td>\n";
↓変更
echo "<td>■<a href=\"$cfg[home]$row[path]\">".$row[title]."</a></td>\n";
102行目
echo " ■<a href=\"$cfg[script]?mode=dir&path=$row[path]\">$row[title]";
↓変更
echo " ■<a href=\"$cfg[home]$row[path]\">$row[title]";
117行目
echo " ■<a href=\"$cfg[script]?mode=dir&path=$row[path]\">$row[title]@</a>";
↓変更
echo " ■<a href=\"$cfg[home]$row[path]\">$row[title]@</a>";
258行目
$navi .= "<a href=\"$cfg[script]?mode=dir&path=$path\">$row[title]</a> > ";
↓変更
$navi .= "<a href=\"$cfg[home]$path\">$row[title]</a> > ";
RSSの静的化設定
また、RSS出力機能追加を行っている場合は、追加で下記のテンプレートに変更してください。
.htaccessファイル末に追加記述
#RSS設定
RewriteRule ^([0-9]+)/rss.xml$ index.php?mode=dir&path=$1/&output=xml
RewriteRule ^([0-9]+)/([0-9]+)/rss.xml$ index.php?mode=dir&path=$1/$2/&output=xml
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/rss.xml$ index.php?mode=dir&path=$1/$2/$3/&output=xml
RewriteRule ^rss.xml$ index.php?mode=new&path=&output=xml
template/category.htm の5行目に追加
<title><?=$title?></title>
<link rel="alternate" type="application/rss+xml" href="<?=$cfg[home]?><?=$_GET["path"]?>rss.xml" />
<link rel="stylesheet" href="style.css" type="text/css">
template/top.htm の5行目に追加
<title><?=$cfg[search_name]?></title>
<link rel="alternate" type="application/rss+xml" href="<?=$cfg[home]?>rss.xml" />
<link rel="stylesheet" href="style.css" type="text/css">