簡體   English   中英

301從舊URL重定向不起作用(prestashop)

[英]301 Redirect from old URL not working (prestashop)

我有一個現有域的新站點。

我想將舊的URL重定向到新站點,但是簡單的方法是:重定向301 oldURL newURL不起作用。

有人告訴我,舊網址中包含index.php是有問題的,我需要為其重寫規則...

新/舊網址的示例:

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

新增: http : //www.example.com/64-white-

希望對我需要插入HTACCESS的規則有所幫助

提前發送

家伙

有幾種方法可以在.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]

雖然,由於您正在談論從index.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;
}
?>

並在index.php文件中的所有代碼和注釋上方添加以下行:

require_once('oldsite_redirects.php');

希望這可以幫助。

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

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

由於url重寫,我認為不可能使用正則表達式。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM