設置的前提:你的虛擬主機必須支持apache mod_Rewrite! 你可以在你的虛擬主機控制面板查找或詢問主機商,目前國外很多主流主機商的PHP主機都是默認支持該功能的.
設置方法:
首先:
打開 /includes/application_top.php
查找
define('PAGE_PARSE_START_TIME', microtime());
插入
require('seflt.php');
打開 /includes/application_bottom.php
在?>前插入
ob_end_flush();
其次:
創建.htaccess ; 內容如下:
RewriteEngine on
RewriteBase /
RewriteRule ^([a-z]{2})/(.*)$ Ū?language=ũ&%{QUERY_STRING}
RewriteRule ^manufacturer([0-9{}]+_?[0-9{}]*)(/?.*)$ Ū?manufacturers_id=ũ&%{QUERY_STRING}
RewriteRule ^product([0-9{}]+_?[0-9{}]*)(/?.*)$ Ū?products_id=ũ&%{QUERY_STRING}
RewriteRule ^category([_0-9]+)/(.*)$ Ū?cPath=ũ&%{QUERY_STRING}
RewriteRule ^(.*)\.html(.*)$ ũ.php?%{QUERY_STRING}
再次:
創建seflt.php ; 內容如下:
/*
SEF Link Transformer for osCommerce (SEF stand for Search Engine Friendly)
Version: Lite 0.8.0 Alpha
Author: Silencer (silencer@softhome.net)
Release date: 26 November 2003
Legal notices: i don't care about all legal stuff, too lazy to attach GNU GPL licence,
so forget it. But DO NOT remove my name and as always NO WARRANTIES.
Installation instructions: see readme.txt
Warning - do not use this on heavy loaded shops (more than 10000 visitors per day)
if you not on dedicated server.
*/
function callback($pagecontent) {
$pagecontent = preg_replace_callback("/(<[Aa][ \r\n\t]{1}[^>]*href[^=]*=[ '\"\n\r\t]*)([^ \"'>\r\n\t#]+)([^>]*>)/",'wrap_href',$pagecontent);
return $pagecontent;
}
function transform_uri($param) {
$uriparts = parse_url($param[2]);
$newquery='';
$scheme = $uriparts['scheme'].'://';
if (($scheme != 'http://') && ($scheme != 'https://')) return $param[1].$param[2].$param[3];
$host = $uriparts['host'];
if ($host != $_SERVER['SERVER_NAME'] && $host != $_SERVER['SERVER_ADDR']) return $param[1].$param[2].$param[3];
$host .= '/';
$path = $uriparts['path'];
list($file,$extension) = explode('.', basename($path));
if($extension != 'php') return $param[1].$param[2].$param[3];
$extension = ".html";
$path = rtrim(dirname($path),'/');
$query = $uriparts['query'];
$anchor = $uriparts['anchor'];
if ($a = explode('&',$query)){
foreach ($a as $b) {
list($key,$val) = split('=',$b);
switch ($key) {
case 'cPath':
$path = 'category'.$val.'/'.$path;
break;
case 'language':
$path = $val.'/'.$path;
break;
case 'products_id':
$path .= 'product'.$val.'/'
break;
case 'manufacturers_id':
$path .= 'manufacturer'.$val.'/'
break;
case 'osCsid':
if(strstr($_SERVER["HTTP_USER_AGENT"],'Mozilla')) $newquery .= $key.'='.$val.'&'
break;
default:
if($newquery &line;&line; $key) $newquery .= $key.'='.$val.'&'
}
}
}
if ($newquery) $newquery = '?'.rtrim($newquery,'&');
return $param[1].$scheme.$host.$path.$file.$extension.$newquery.$anchor.$param[3];
}
function wrap_href($param) {
return transform_uri($param);
}
ob_start("callback");
?>
最後:
上傳文件.htaccess、seflt.php到你的虛擬主機的OSC根目錄下.
1 則留言:
建議改用 OSC 2.3.1 台灣中文版 ( 2011 年釋出 ) ,
Demo 站 : http://demo.twosc.com
台灣 OSC 社群 : http://www.twosc.com
張貼留言