我们正在使用我们的电子商务网站ECT模板,并安装了程序员的代码,该代码将动态网址更改为静态网址。但是,我们有一些反向链接,我们希望将其重定向到正确的页面(或者我们会将它们全部发送到我们已设置的“所有产品”页面。重定向我们当前返回的页面显示“该产品已被删除。“不好!
以下是htaccess文件中动态到静态的代码:
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*)$ /handle_url.php [L]
以下是handle_url.php文件中的代码:
<?php
ob_start();
session_start();
include "vsadmin/db_conn_open.php";
function sli_escape_string($estr){
if(version_compare(phpversion(),'4.3.0')=='-1') return(mysql_escape_string(trim($estr))); else return(mysql_real_escape_string(trim($estr)));
}
$url = $_SERVER['REQUEST_URI'];
$url = trim($url, "/");
$pos = strpos($url,'?');
if ($pos > 0){
$url = substr($url,0,$pos);
}
$pos = strpos($url,".");
if ($pos > 0){
$urlspec = substr($url, 0, $pos);
} else {
}
$store_url = $url;
$sSQL = "SELECT pID FROM products WHERE pURL='" . sli_escape_string($url) . "'";
$query = mysql_query($sSQL);
if ($query && mysql_num_rows($query)>0){
$rs = mysql_fetch_assoc($query);
$_GET['prod']=$rs['pID'];
$explicitid=$rs['pID'];
include "proddetail.php";
$plid = $explicitid;
} else {
$sSQL = "SELECT sectionID, rootSection FROM sections WHERE sectionURL='".sli_escape_string($url)."'";
$query = mysql_query($sSQL);
if ($query && mysql_num_rows($query)>0){
$rs = mysql_fetch_assoc($query);
$_GET['cat']=$rs['sectionID'];
$explicitid=$rs['sectionID'];
$secid = $explicitid;
if ($rs['rootSection']==1){
include "products.php";
} else {
include "categories.php";
}
} else {
include "content.php";
}
}
// For sections we want the .html
?>
以下是我尝试使用旧的动态链接发送到静态页面的失败(没有换行符):
redirect 301 /proddetail.php?prod=cooling-hydration-backpack-system http://www.veskimo.com/cooling-hydration-backpack-system.html
我非常感谢你能给我的任何帮助。我承认我对此有点不了解。 非常感谢, Janell
答案 0 :(得分:0)
尝试将以下内容添加到站点根目录中的.htaccess
文件中。
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /proddetail\.php\?prod=cooling-hydration-backpack-system [NC]
RewriteRule ^ http://www.veskimo.com/cooling-hydration-backpack-system.html [L,R=301]