Remove index.php?route=common/home from OpenCart

前端 未结 15 1118
太阳男子
太阳男子 2020-11-29 04:56

I currently have User SEO URL\'s set to Yes in OpenCart Admin.

System -> Settings -> Store -> Server -> User SEO URL\'s

15条回答
  •  [愿得一人]
    2020-11-29 05:26

    OpenCart 3.x

    First of all in root folder of your website rename htaccess.txt into .htaccess.

    Then go to System > Settings > Your store. Edit. Open tab Server and set Use SEO URLs to Yes.

    Now open catalog/controller/startup/seo_url.php

    Find } elseif ($key == 'path') {

    Add before

    } elseif ($key == 'route') {
      $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
     
      if ($query->num_rows && $query->row['keyword']) {
        $url .= '/' . $query->row['keyword'];
        unset($data[$key]);
      } else if ($data['route'] == "common/home") { 
        $url .= '/'; 
      } 
    

    Now /index.php?route=common/home becames /

    And now you can although set SEO URLs in Design > SEO URL using constructions like account/login or information/contact.

提交回复
热议问题