0

我正在使用 Magento 构建一个虚拟商店,并且我正在使用带有“M”计划的 HostGator 托管,它支持多个站点,问题是 Magento 在根目录中,我在文件夹中有另一个站点/example.com.br,但是当我尝试通过浏览器访问此站点时:

http://example.com.br

我被重定向到 Magento 网站:

http://magentosite.com.br/maintenance.html

根文件夹(magento 的 htaccess)上的 htaccess 正在重定向到 magento 维护页面http://magentosite.com.br/maintenance.html,我只需要保留 Magento 进行维护,而不是某些文件夹中的站点,如文件夹/example.com.br/example2.com.br...

这是我在 Magento 中使用的维护代码(在 Root 中):

RewriteEngine On
RewriteBase /
# allow my ip to access magento store
RewriteCond %{REMOTE_ADDR} !^177\.18\.228\.58
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ https://magentosite.com.br/maintenance.html [R=307,L]

我尝试了这个解决方案https://stackoverflow.com/a/6528448/2761794但对我不起作用......

4

1 回答 1

0

我使用了 Magento 的维护模式,而不是使用“maintenance.flag”文件,而是创建了我的自定义文件并重定向了它,因此我不必更改 htaccess 文件,因此子文件夹中的其他站点可以正常工作。

我将此代码添加到 Magento 根目录的 index.php 中:

$maintenanceFile = 'maintenance.html';
$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('177.99.108.78', 'another ip...');

if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
    // include_once dirname(__FILE__) . '/errors/503.php';
    include_once dirname(__FILE__) . '/maintenance.html';
    exit;
}
于 2017-01-01T14:28:07.663 回答