conant

問(wèn)一下 通王CMS怎么設(shè)置301重定向

win主機(jī)環(huán)境 怎么設(shè)置301重定向 在代碼里實(shí)現(xiàn) 求解答
#1樓
發(fā)帖時(shí)間:2013-1-25   |   查看數(shù):273   |   回復(fù)數(shù):11
空城
PHP代碼實(shí)現(xiàn)

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://bbs.twcms.com');
?>
2013-1-25 #2樓
conant
空城 發(fā)表于 2013-1-25 14:42
PHP代碼實(shí)現(xiàn)


加到根目錄 index.php 這個(gè)文件里嗎
2013-1-25 #3樓
conant
/**
* [TWCMS] (C)2012 TongWang Inc.
* $Id: index.php 475 2013-01-12 06:22:20Z wuzhaohuan $
*/
error_reporting(0);
$starttime = microtime(true);
$memory = memory_get_usage();
define('IN_TWCMS', true);
define('D', DIRECTORY_SEPARATOR);
define('TWCMS_DIR', 'twcms'); #核心目錄
define('TWCMS_ROOT', dirname(__FILE__).D); #根目錄
define('TWCMS_CORE', TWCMS_ROOT.TWCMS_DIR.D); #核心目錄絕對(duì)路徑
require TWCMS_CORE.'index.php';
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.adsemer.net/');

?>

這樣加 對(duì)吧?
2013-1-25 #4樓
conant
空城 發(fā)表于 2013-1-25 14:42
PHP代碼實(shí)現(xiàn)


/**
* [TWCMS] (C)2012 TongWang Inc.
* $Id: index.php 475 2013-01-12 06:22:20Z wuzhaohuan $
*/
error_reporting(0);
$starttime = microtime(true);
$memory = memory_get_usage();
define('IN_TWCMS', true);
define('D', DIRECTORY_SEPARATOR);
define('TWCMS_DIR', 'twcms'); #核心目錄
define('TWCMS_ROOT', dirname(__FILE__).D); #根目錄
define('TWCMS_CORE', TWCMS_ROOT.TWCMS_DIR.D); #核心目錄絕對(duì)路徑
require TWCMS_CORE.'index.php';
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.adsemer.net/');

?>
這樣加 對(duì)嗎  301跳轉(zhuǎn)是實(shí)現(xiàn)了 可是首頁(yè)訪問(wèn)不了了
2013-1-25 #5樓
conant
conant 發(fā)表于 2013-1-25 16:41
加到根目錄 index.php 這個(gè)文件里嗎


求解 謝謝
2013-1-25 #6樓
空城
主要你想實(shí)現(xiàn)什么功能,從什么頁(yè)面跳轉(zhuǎn)到什么頁(yè)面?
2013-1-25 #7樓
conant
空城 發(fā)表于 2013-1-25 17:40
主要你想實(shí)現(xiàn)什么功能,從什么頁(yè)面跳轉(zhuǎn)到什么頁(yè)面?


就是實(shí)現(xiàn)這樣的效果

我的域名www.xx.com    輸入xx.com的時(shí)候 301重定向到 www.xx.com
2013-1-25 #8樓
空城
[code]
if($_SERVER["HTTP_HOST"] == 'adsemer.net') {
        header('HTTP/1.1 301 Moved Permanently');
        header('Location: http://www.adsemer.net/');
        exit();
}[/code]這個(gè)加在index.php頂部

這只能在動(dòng)態(tài)時(shí)支持的,要是在html的話只能用JS做跳轉(zhuǎn),不能301

2013-1-25 #9樓
conant
空城 發(fā)表于 2013-1-25 17:56
這個(gè)加在index.php頂部

這只能在動(dòng)態(tài)時(shí)支持的,要是在html的話只能用JS做跳轉(zhuǎn),不能301


噢 靜態(tài)想301的話 沒(méi)有好的解決方案嗎:(
2013-1-25 #10樓
心尋
過(guò)來(lái)看看。順便也學(xué)習(xí)一下怎么實(shí)現(xiàn)301重定向。:)
2013-1-26 #11樓
空城
conant 發(fā)表于 2013-1-25 19:58
噢 靜態(tài)想301的話 沒(méi)有好的解決方案嗎


其他方案,只能用服務(wù)器環(huán)境支持才行,可以用.htaccess來(lái)實(shí)現(xiàn)
2013-1-26 #12樓
游客組