设置的前提:你的虚拟主机必须支持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 ; 内容如下:
<?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根目录下.