.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?pathinfo=$1 [QSA,L]
index.php
<?php
// This file will generate and return the main page of the site
if( isset($_GET["pathinfo"] ) ){
$_SERVER["PATH_INFO"] = $_GET["pathinfo"] ;
}
$CONF = array();
$CONF['Self'] = '';
include('./config.php');
selector();
?>
Nucleusではバージョン2.0からグローバル設定において「URLモード」というオプションを設けています。ここを「FancyURLモード」に設定して以下の作業を行うと、URLが「http://example.org/index.php?itemid=1234」から「http://example.org/item/1234」に変わります。このURL形式の方が検索エンジンに登録されやすくなります。
■ .htaccess の変更
ForceType application/x-httpd-php は
ForceType application/x-httpd-cgi に変更
■ extra/fancyurls/* の変更
・先頭に "#! /usr/local/bin/php" の追加
・serverVar('PATH_INFO') を serverVar('ORIG_PATH_INFO') に変更
でrootにコピー(実行属性付けてね)
(※ fancyurls.config.phpは先頭にパスを追加しない)
・include('./ を include(' に変更 ( ./ を消す)
■ php.ini の編集
cgi.force_redirect=0
cgi.fix_pathinfo=1
■ libs/globalfunctions.php の変更
・262行目あたりの、
serverVar('PATH_INFO') を serverVar('ORIG_PATH_INFO') に変更
サイトのrootじゃなくてNucleus配下に専用の.htaccessやphp.iniを置くのが良い
※NP_CustomURLの導入も検討されたし。上記のような面倒なことをしなくても一発でスラッシュ区切りのURLにできる。
cgi.fix_pathinfo = 1
cgi.force_redirect =0
index.php の $CONF['Self'] を、説明にあるとおり 「''」にして、
(index.phpの記述を$CONF['Self'] = '';に変更する)
グローバル設定でモードを Fancy にする
で、.htaccess に
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Internal Server Error
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
No input file specified.
.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?pathinfo=$1 [QSA,L]
<?php
// This file will generate and return the main page of the site
if( isset($_GET["pathinfo"] ) ){
$_SERVER["PATH_INFO"] = $_GET["pathinfo"] ;
}
$CONF = array();
$CONF['Self'] = '';
include('./config.php');
selector();
?>
http://hain.jp/htsrv/trackback.php/146
No Comments/Trackbacks for this post yet...
極論istの技術屋を始めて早幾年。 流れの速い業界の波にもまれながらも精一杯生きている様をとくとごらんあれ。