【问题标题】:htaccess maintenance redirect, but exclude some folders (hostgator multsite plan)htaccess 维护重定向,但排除一些文件夹(hostgator 多站点计划)
【发布时间】:2016-12-10 13:10:25
【问题描述】:

我正在使用 Magento 构建一个虚拟商店,并且我正在使用带有 "M" plan 的 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,但对我不起作用...

【问题讨论】:

    标签: apache .htaccess magento redirect maintenance-mode


    【解决方案1】:

    我使用 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;
    }
    

    【讨论】:

      猜你喜欢
      • 2021-06-13
      • 2011-03-25
      • 2017-04-07
      • 2017-05-31
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2014-10-17
      相关资源
      最近更新 更多