【发布时间】:2011-02-08 07:25:15
【问题描述】:
我有 2 个网址,例如 http://www.abc.com 和 http://www.xyz.com。
每当我在浏览器中输入http://www.abc.com 时,我都会尝试重定向到http://www.xyz.com。
而且当用户输入http://www.abc.com/index.php?option=com_content&view=article&id=46&Itemid=55 类似这样的东西时。 abc.com 旁边的任何查询然后我试图重定向到http://www.xyz.com/index.php?option=com_content&view=article&id=46&Itemid=55。
如何在 PHP 中做到这一点...请帮助我..
编辑: 我在模板文件中用 php 编写了一个脚本以重定向为
<?php
if(curPageURL()=="http://localhost/joomla/Joomla_1.5.7/"){
header("Location: http://localhost/joomla/Joomla_1.5.7copy/");
}
// else if(curPageURL()=="http://localhost/joomla/Joomla_1.5.7/"){}
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
如果我试图检查http://localhost/joomla/Joomla_1.5.7/ 是否在网址旁边有任何查询,例如http://localhost/joomla/Joomla_1.5.7/index.php?option=com_content&view=section&layout=blog&id=3&Itemid=55
所以我必须将查询放在它旁边并将其附加到
http://localhost/joomla/Joomla_1.5.7copy/index.php?option=com_content&view=section&layout=blog&id=3&Itemid=55..
【问题讨论】: