Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 301从旧URL重定向不起作用(prestashop)_Php_.htaccess_Mod Rewrite_Redirect_Prestashop - Fatal编程技术网

Php 301从旧URL重定向不起作用(prestashop)

Php 301从旧URL重定向不起作用(prestashop),php,.htaccess,mod-rewrite,redirect,prestashop,Php,.htaccess,Mod Rewrite,Redirect,Prestashop,我有一个现有域的新站点 我想将旧URL重定向到新站点,但方法很简单: 重定向301 oldURL newURL 它不起作用了 我被告知旧URL中包含index.php这一事实存在问题, 我需要一个重写规则 新/旧URL示例: 旧的: 新的: 如果您能提供我需要插入HTACCESS的规则,我将不胜感激 tnx前进 Guy要在htaccess文件中进行永久重定向,可以使用RedirectPermanent: RedirectPermanent /index.php?type=store&ca

我有一个现有域的新站点

我想将旧URL重定向到新站点,但方法很简单: 重定向301 oldURL newURL 它不起作用了

我被告知旧URL中包含index.php这一事实存在问题, 我需要一个重写规则

新/旧URL示例:

旧的:

新的:

如果您能提供我需要插入HTACCESS的规则,我将不胜感激

tnx前进


Guy

要在htaccess文件中进行永久重定向,可以使用RedirectPermanent:

RedirectPermanent /index.php?type=store&category=11&subcategory=15&item=67 http://www.example.com/64-white-

由于url重写,我认为不可能使用正则表达式。

有几种方法可以在.htaccess中创建永久重定向:

RedirectPermanent /index.php?type=store&category=11&subcategory=15&item=67 http://www.example.com/64-white-
Redirect 301 /index.php?type=store&category=11&subcategory=15&item=67 http://www.example.com/64-white-
RedirectRule /index.php?type=store&category=11&subcategory=15&item=67 http://www.example.com/64-white- [L,R=301]

不过,既然您正在谈论从索引.php重定向,我建议您考虑在代码中执行重定向。

例如,您可以像下面这样创建一个oldsite_redirects.php文件:

<?php
$redir_maps = array(
'/index.php?type=store&category=11&subcategory=15&item=67' => '/64-white-'
);

if(in_array(@$_SERVER['REQUEST_URI'], array_keys($redir_maps))){
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: ".$redir_maps[@$_SERVER['REQUEST_URI']]);
exit;
}
?>

希望这有帮助。

服务器管理员告诉我,这就是我需要使用重写规则的原因。只是我不知道规则应该是什么。。。
require_once('oldsite_redirects.php');