ecshop在IIS7 8上的rewrite重写规则web.config

ecshop在IIS7 8上的rewrite重写规则web.config,以下才是正确姿势:

其实iisrewrite配置成功后,相应的rewrite规则写到根目录的web.config文件中即可。ecshop2.7.3对应的规则如下

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index" stopProcessing="true">
<match url="^index.html" />
<action type="Rewrite" url="index.php" />
</rule>
<rule name="Feed-C" stopProcessing="true">
<match url="^feed-c([0-9]+).xml" />
<action type="Rewrite" url="feed.php?cat={R:1}" />
</rule>
<rule name="Feed-B" stopProcessing="true">
<match url="^feed-b([0-9]+).xml" />
<action type="Rewrite" url="feed.php?brand={R:1}" />
</rule>
<rule name="Feed" stopProcessing="true">
<match url="^feed.xml" />
<action type="Rewrite" url="feed.php" />
</rule>
<rule name="Category6" stopProcessing="true">
<match url="^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
<action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;price_min={R:3}&amp;price_max={R:4}&amp;filter_attr={R:5}&amp;page={R:6}&amp;sort={R:7}&amp;order={R:8}" />
</rule>
<rule name="Category5" stopProcessing="true">
<match url="^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*).html" />
<action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;price_min={R:3}&amp;price_max={R:4}&amp;filter_attr={R:5}" />
</rule>
<rule name="Category4" stopProcessing="true">
<match url="^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
<action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;page={R:3}&amp;sort={R:4}&amp;order={R:5}" />
</rule>
<rule name="Category3" stopProcessing="true">
<match url="^category-([0-9]+)-b([0-9]+)-([0-9]+).html" />
<action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;page={R:3}" />
</rule>
<rule name="Category2" stopProcessing="true">
<match url="^category-([0-9]+)-b([0-9]+).html" />
<action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}" />
</rule>
<rule name="Category1" stopProcessing="true">
<match url="^category-([0-9]+).html" />
<action type="Rewrite" url="category.php?id={R:1}" />
</rule>
<rule name="Goods" stopProcessing="true">
<match url="^goods-([0-9]+).html" />
<action type="Rewrite" url="goods.php?id={R:1}" />
</rule>
<rule name="Cat3" stopProcessing="true">
<match url="^article_cat-([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
<action type="Rewrite" url="article_cat.php?id={R:1}&amp;page={R:2}&amp;sort={R:3}&amp;order={R:4}" />
</rule>
<rule name="Cat2" stopProcessing="true">
<match url="^article_cat-([0-9]+)-([0-9]+).html" />
<action type="Rewrite" url="article_cat.php?id={R:1}&amp;page={R:2}" />
</rule>
<rule name="Cat1" stopProcessing="true">
<match url="^article_cat-([0-9]+).html" />
<action type="Rewrite" url="article_cat.php?id={R:1}" />
</rule>
<rule name="Articles" stopProcessing="true">
<match url="^article-([0-9]+).html" />
<action type="Rewrite" url="article.php?id={R:1}" />
</rule>
<rule name="Brand4" stopProcessing="true">
<match url="^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
<action type="Rewrite" url="brand.php?id={R:1}&amp;cat={R:2}&amp;page={R:3}&amp;sort={R:4}&amp;order={R:5}" />
</rule>
<rule name="Brand3" stopProcessing="true">
<match url="^brand-([0-9]+)-c([0-9]+)-([0-9]+).html" />
<action type="Rewrite" url="brand.php?id={R:1}&amp;cat={R:2}&amp;page={R:3}" />
</rule>
<rule name="Brand2" stopProcessing="true">
<match url="^brand-([0-9]+)-c([0-9]+).html" />
<action type="Rewrite" url="brand.php?id={R:1}&amp;cat={R:2}" />
</rule>
<rule name="Brand1" stopProcessing="true">
<match url="^brand-([0-9]+).html" />
<action type="Rewrite" url="brand.php?id={R:1}" />
</rule>
<rule name="Search" stopProcessing="true">
<match url="^tag-([_0-9a-z-]+).html" />
<action type="Rewrite" url="search.php?keywords={R:1}" />
</rule>
<rule name="Snatch" stopProcessing="true">
<match url="^snatch-([0-9]+).html" />
<action type="Rewrite" url="snatch.php?id={R:1}" />
</rule>
<rule name="Group_Buy" stopProcessing="true">
<match url="^group_buy-([0-9]+).html" />
<action type="Rewrite" url="group_buy.php?act=view&amp;id={R:1}" />
</rule>
<rule name="Auction" stopProcessing="true">
<match url="^auction-([0-9]+).html" />
<action type="Rewrite" url="auction.php?act=view&amp;id={R:1}" />
</rule>
<rule name="Exchange5" stopProcessing="true">
<match url="^exchange-id([0-9]+).html" />
<action type="Rewrite" url="exchange.php?id={R:1}&amp;act=view" />
</rule>
<rule name="Exchange4" stopProcessing="true">
<match url="^exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
<action type="Rewrite" url="exchange.php?cat_id={R:1}&amp;integral_min={R:2}&amp;integral_max={R:3}&amp;page={R:4}&amp;sort={R:5}&amp;order={R:6}" />
</rule>
<rule name="Exchange3" stopProcessing="true">
<match url="^exchange-([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
<action type="Rewrite" url="exchange.php?cat_id={R:1}&amp;page={R:2}&amp;sort={R:3}&amp;order={R:4}" />
</rule>
<rule name="Exchange2" stopProcessing="true">
<match url="^exchange-([0-9]+)-([0-9]+).html" />
<action type="Rewrite" url="exchange.php?cat_id={R:1}&amp;page={R:2}" />
</rule>
<rule name="Exchange1" stopProcessing="true">
<match url="^exchange-([0-9]+).html" />
<action type="Rewrite" url="exchange.php?cat_id={R:1}" />
</rule>
<rule name="Topic" stopProcessing="true">
<match url="^topic-([0-9]+).html" />
<action type="Rewrite" url="topic.php?topic_id={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

一开始网站试了很多规则,都提示某行错误,白色不得其解,后来发现是“&”搞的鬼,把对应的“&”都修改为“&amp;”即可。

解决ecshop后台频繁退出问题

ecshop后台有时候会自动登出,而且还会很频繁,频繁的自动登出就严重的影响到了后台使用。

首先我们可以通过 在后台登录时勾选保存登录来解决.

如果以上方法不能解决,可以尝试通过修改代码来解决.

打开/includes/lib_base.php

找到function real_ip()函数

修改成以下代码

function real_ip()
{
static $realip = NULL;

if ($realip !== NULL)
{
return $realip;
}

/*添加*/
if(isset($_COOKIE['real_ipd']) &amp;&amp; !empty($_COOKIE['real_ipd'])){
$realip = $_COOKIE['real_ipd'];
return $realip;
}
/*添加*/

if (isset($_SERVER))
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);

/* 取X-Forwarded-For中第一个非unknown的有效IP字符串 */
foreach ($arr AS $ip)
{
$ip = trim($ip);

if ($ip != 'unknown')
{
$realip = $ip;

break;
}
}
}
elseif (isset($_SERVER['HTTP_CLIENT_IP']))
{
$realip = $_SERVER['HTTP_CLIENT_IP'];
}
else
{
if (isset($_SERVER['REMOTE_ADDR']))
{
$realip = $_SERVER['REMOTE_ADDR'];
}
else
{
$realip = '0.0.0.0';
/*添加*/ setcookie(&quot;real_ipd&quot;, $realip, time()+36000, &quot;/&quot;); /*添加*/
}
}
}
else
{
if (getenv('HTTP_X_FORWARDED_FOR'))
{
$realip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif (getenv('HTTP_CLIENT_IP'))
{
$realip = getenv('HTTP_CLIENT_IP');
}
else
{
$realip = getenv('REMOTE_ADDR');
}
}

preg_match(&quot;/[d.]{7,15}/&quot;, $realip, $onlineip);
$realip = !empty($onlineip[0]) ? $onlineip[0] : '0.0.0.0';

return $realip;
}

可以直接用上面的代码覆盖,记得提前备份.

ecshop新添商品提示"此商品不存在规格,请为其添加规格"的解决方法

ecshop新添商品提示"此商品不存在规格,请为其添加规格"的解决方法

因为业务需求,网站新增了案例展示功能,同时添加了商品类型,在新增案例,提交后,会显示"此商品不存在规格,请为其添加规格"的提示。

经过对添加商品相关文件的分析,终于找到了解决方法,只需在 /admin/includes/lib_goods.php文件中添加一行代码AND a.attr_type = 1,添加位置如下:

/**
 * 检查单个商品是否存在规格
 *
 * @param   int        $goods_id          商品id
 * @return  bool                          true,存在;false,不存在
 */
function check_goods_specifications_exist($goods_id)
{
    $goods_id = intval($goods_id);

    $sql = "SELECT COUNT(a.attr_id)
            FROM " .$GLOBALS['ecs']->table('attribute'). " AS a, " .$GLOBALS['ecs']->table('goods'). " AS g
            WHERE a.cat_id = g.goods_type
            AND g.goods_id = '$goods_id'
            AND a.attr_type = 1";
    $count = $GLOBALS['db']->getOne($sql);

    if ($count > 0)
    {
        return true;    //存在
    }
    else
    {
        return false;    //不存在
    }
}

请注意
AND g.goods_id = '$goods_id'
AND a.attr_type = 1";
这两行代码部分。

在修改前,请注意备份原文件,以防不测。

通过以上修改后,就解决了新添商品提示"此商品不存在规格,请为其添加规格"的问题。

Ecshop购物车只能放入一个商品?

最近在用Ecshop给公司做个网站,测试时发现购物车只能放入一个商品,新加入商品后,原来的车里的商品就被替换掉了。
还有就是购物车里商品的数量也不能修改。

这显然是非常不科学的购物体验,后经排查,这个情况不是代码问题。而是后台设置的问题。

在后台中,有这样一处设置:后台管理-》系统设置-》商店设置-》购物流程-》是否是否一步购物:  选择 是或否

选择否,则可以解决Ecshop购物车只能放入一个商品的问题。

选择是,则是一次性购物的形式。

哪种选择好呢,这个要根据自己Ecshop网站的商品来分析。

至此,本文结束,更多网站建设相关问题,可以加QQ群 122019913咨询,请备注相关信息。