prestashop 1.6中的重定向循环问题

时间:2015-01-02 04:18:54

标签: .htaccess migration prestashop infinite-loop prestashop-1.6

我已经在我的本地Wamp服务器上安装了Prestashop 1.6,它运行正常。当我将这个商店移到实际的在线域名时,它在Chrome中显示为“此网页有一个重定向循环”,并且在Firefox中显示“该页面没有正确重定向”。 似乎已经错过了一些配置。我在ps_shop_url中更改了值并在htaccess中进行了更改,但仍然是相同的。

请帮忙

4 个答案:

答案 0 :(得分:4)

在ps_shop_url表中,您必须设置domain = localhost,domain_ssl = localhost& physical_uri = / myProject的/

在ps_configuration中设置PS_SHOP_DOMAIN_SSL& PS_SHOP_DOMAIN到localhost

另请参阅BackOffice - >偏好 - > SEO& URL并单击[保存] - 这将重新生成.htaccess文件,并在需要的地方添加/ myProject。

答案 1 :(得分:1)

  • 转到表格" ps_configuration "并找到记录 PS_SHOP_DOMAIN PS_SHOP_DOMAIN_SSL ,设置正确的值。

  • 转到表格" ps_shop_url "并设置正确的值,如果你有子商店或虚拟主机,请注意,大多数错误来自这里。 这是一个例子: http://i.stack.imgur.com/J947r.jpg

  • 在文件config / settings.inc.php中编辑此=> 定义(' _DB_NAME _',' your_datase_name ');

  • 删除应用程序文件夹根目录下的.htaccess。

  • 通过禁用和启用简化网址,在后台重新生成.htaccess。

答案 2 :(得分:0)

首先检查表_shop_url并设置以下内容,

  • = localhost
  • domain_ssl = localhost
  • physical_uri = / yourfoldername /

并且不要忘记使用.htaccess文件。

如果您没有本地部署的.htaccess文件,请点击以下链接。不要忘记用文件夹名称替换字符串 yourproject

.htaccess file for localhost deployment

答案 3 :(得分:-1)

Oliver的答案是恰当的,但是如果您想以编程方式进行操作(例如,复制设置以在同一域上创建新实例):

/**
* Update the access file of the new sub-domain. Otherwise the user will 
* constantly be redirected to the setup.
*
* @param $errorMessage String array to return the error message.
* @param $name String name of the subdomain to update.
*
* @return Boolean
*/
private function updateAccessFile(&$errorMessage, $name){

    $success = false;

    $fileContent = file_get_contents(realpath(dirname(__FILE__)) . '/../../' . $name . "/.htaccess");

    if ($fileContent !== false){

        $filcontent = str_replace("setup", $name, $fileContent);

        $success = boolval(file_put_contents(realpath(dirname(__FILE__)) . '/../../' . $name . "/.htaccess", $filcontent));
    }

    if (!$success){

        $errorMessage[] = parent::getErrorMessage("SUBDOMAIN_CREATION_CONF_FILE_ERR", "We are not able to update the prestashop main access file.");    
    }

    return $success;
}


/**
* Update the configuration file with the configuration for the new subdomain 
* in order to access the sub-domain affiliated database.
*
* @param $errorMessage String array to return the error message.
* @param $name String name of the subdomain to update.
*
* @return Boolean
*/
private function updateConfigurationFile(&$errorMessage, $name){

    $counter = 0;

    $reader = fopen(realpath(dirname(__FILE__)) . '/../../' . $name .'/config/settings.inc.php', 'r');
    $writter = fopen(realpath(dirname(__FILE__)) . '/../../' . $name .'/config/temp.txt', 'w');

    while (!feof($reader)) {

      $line = fgets($reader);

      if (strpos(strtoupper($line), '_DB_SERVER_') !== false) {

        $line = "define('_DB_SERVER_', '127.0.0.1');\n";

        $counter++;
      }
      elseif (strpos(strtoupper($line), '_DB_NAME_') !== false) {

        $line = "define('_DB_NAME_', '" . $name . "');\n";

        $counter++;
      }
      elseif (strpos(strtoupper($line), '_COOKIE_KEY_')  !== false and !empty($this->fetchEncryptionKey())) {

        $line = "define('_COOKIE_KEY_', '" . $this->saltKey . "');\n";

        $counter++;
      }


      fputs($writter, $line);
    }

    fclose($reader); 

    fclose($writter);

    if ($counter > 0){

        rename(realpath(dirname(__FILE__)) . '/../../' . $name .'/config/temp.txt', realpath(dirname(__FILE__)) . '/../../' . $name .'/config/settings.inc.php');   

    }
    else{

        unlink(realpath(dirname(__FILE__)) . '/../../' . $name .'/config/temp.txt');
    }

    if ($counter !== 3){

        $errorMessage[] = parent::getErrorMessage("SUBDOMAIN_CREATION_CONF_FILE_ERR", "We are not able to update prestashop configuration file.");  
    }

    return (empty($errorMessage) ? true : false);
}

数据库的存储过程:

DELIMITER $$

CREATE PROCEDURE setupStore(IN shopName VARCHAR(50), IN domain VARCHAR(50), IN encryptionKey CHAR(56), OUT success BOOLEAN)

BEGIN
    DECLARE fail BOOLEAN DEFAULT false;

    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET fail = true;

    START TRANSACTION;

    SET success = false;

    SET @shop = shopName;

    SET @domain = domain;

    SET @uri = CONCAT('/', shopName, '/');


    SET @query = 'UPDATE ps_shop s INNER JOIN ps_shop_url su ON s.id_shop = su.id_shop SET s.name=?, su.domain=?, su.domain_ssl=?, su.physical_uri=? WHERE s.id_shop=1';

    PREPARE statement FROM @query;

    EXECUTE statement USING @shop, @domain, @domain, @uri;



    SET @query = CONCAT('UPDATE ps_configuration SET value= ? where name=', QUOTE('PS_SHOP_DOMAIN'), 'OR name=', QUOTE('PS_SHOP_DOMAIN_SSL'));

    PREPARE statement FROM @query;

    EXECUTE statement USING @domain;


    SET @query = CONCAT('UPDATE ps_configuration SET value= ? where name=', QUOTE('PS_SHOP_NAME'));

    PREPARE statement FROM @query;

    EXECUTE statement USING @shop;


    DELETE FROM pc_import_config;

    SET @query = 'INSERT INTO pc_import_config(cookie_key) VALUES(?)';

    SET @key = encryptionKey;

    PREPARE statement FROM @query;

    EXECUTE statement USING @key;


    IF fail THEN

        ROLLBACK;
    ELSE

        COMMIT;

        SET success = true;
    END IF;

    DEALLOCATE PREPARE statement;

END$$

DELIMITER ;

注意 pc_import_config 不是真正的prestashop表,我使用该表在内存中保存从 DataImporter (从不同数据源导入到不同设置的数据的抽象类)以在 subDomainManager 中使用它(抽象类用于从不同的基本设置创建子域的实例,然后管理它们)。

来自蒙特利尔的Jonathan Parent-Lévesque