【问题标题】:Magento admin url - remove index.php (Godaddy Server)Magento 管理员网址 - 删除 index.php(Godaddy 服务器)
【发布时间】:2013-01-14 18:23:41
【问题描述】:

Magento 安装在 WAMP 上并且工作正常。

站点 URL = 本地主机/商店 管理员 URL = localhost/shop/index.php/admin

我将此 magento 移至 Godaddy 服务器。它不在根文件夹中。该站点位于名为“shop”的子文件夹中

站点 URL = mydomain.com/shop 管理员 URL = mydomain.com/shop/index.php/admin

前端 url 工作正常 - mydomain.com/shop/customer/account/login/

管理 url 不适用于包含的“index.php”。当我删除“index.php”并手动调用 url 时,它就可以工作了。

我希望我的管理员网址为 http://mydomain.com/shop/admin/system_config/edit/....

我的配置

使用 Web 服务器重写 = 是

在 .HTACCESS 中

RewriteBase /shop/

我该如何解决这个问题?

【问题讨论】:

    标签: magento-1.7


    【解决方案1】:

    可以在此处找到替代解决方案: How to remove index.php from admin URL

    【讨论】:

      【解决方案2】:

      要从 Magento 管理 URL 中删除 index.php,请在 Magento 文件夹的 /shop/index.php 文件顶部添加以下代码:

      <?php
          function curPageURL() {
          $pageURL = 'http';
          if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
          $pageURL .= "://";
          if ($_SERVER["SERVER_PORT"] != "80") {
          $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
          } else {
          $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
          }
          return $pageURL;
          }
      
          $curUrl = curPageURL();
          $pos = strpos($curUrl, "index.php");
      
          // Note our use of ===.  Simply == would not work as expected
          // because the position of 'a' was the 0th (first) character.
          if ($pos === false) {
          //echo "The string '$findme' was not found in the string '$mystring'";
          } else {
          //echo "The string '$findme' was found in the string '$mystring'";
          //echo " and exists at position $pos";
          $newUrl = str_replace("index.php/", "", $curUrl);
          header("Location: $newUrl");
          exit;
          }
      ?>
      

      享受:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-11
        • 2019-01-06
        • 2012-11-25
        • 1970-01-01
        • 1970-01-01
        • 2019-08-29
        相关资源
        最近更新 更多