我想使用php 301重定向而不是htaccess移动多个动态URL。PHP 301重定向多个URL
我不能解决如何把它放在一起,虽然我有点出于我的深度,这是迄今为止。
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.new-website/new-folder/ $url="http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$url=str_replace('http://www.website.com/old-folder/','',$url);
echo $url; ");
?>
旧网址:http://www.website.com/old-folder/news-article/full.php?=什么
新网址:http://www.new-website.com/new-folder/news-article/full.php?=什么
我想插入东西后当前URL的第二/即进入页眉位置
/old-folder /之后的任何内容每次都会有所不同。
简单来说,我试图做到这一点:
你尝试用PHP<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.new-website/new-folder/ *insert end of URL from current address bar here* ");
?>
使用''标题(“状态:301永久移动”)'''。 – MrTux 2014-09-02 14:05:11
你应该考虑使用.htaccess来做到这一点,因为你的选择可能倾向于HTTP头分割。 – MrTux 2014-09-02 14:06:29
使用.htaccess或vhost conf文件来定义您的重写,因为它将在服务器上轻得多。 (虽然我猜你不明白重写模块,并且为什么你打算在php中做到这一点?) – user3791372 2014-09-02 14:11:39