Практика
/* Как в OpenCart удалить index.php?route= из всех ссылок? в файле /catalog/controller/common/seo_url.php сделайте такие изменения (выделено жирным) */ class ControllerCommonSeoUrl extends Controller { //**** { if (isset($this->request->get['product_id'])) { $this->request->get['route'] = 'product/product'; } elseif (isset($this->request->get['path'])) { $this->request->get['route'] = 'product/category'; } elseif (isset($this->request->get['manufacturer_id'])) { $this->request->get['route'] = 'product/manufacturer/info'; } elseif (isset($this->request->get['information_id'])) { $this->request->get['route'] = 'information/information'; } else { $this->request->get['route'] = $this->request->get['_route_']; } if (isset($this->request->get['route'])) { return $this->forward($this->request->get['route']); } } public function rewrite($link) { if ($this->config->get('config_seo_url')) { $url_data = parse_url(str_replace('&', '&', $link)); $url = ''; $data = array(); parse_str($url_data['query'], $data); foreach ($data as $key => $value) { if (isset($data['route'])) { if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) { $query = $this->db->query('SELECT * FROM ' . DB_PREFIX . 'url_alias WHERE `query` = ' . $this->db->escape($key . '=' . (int)$value)); if ($query->num_rows) { $url .= '/' . $query->row['keyword']; unset($data[$key]); } } elseif ($key == 'path') { $categories = explode('_', $value); foreach ($categories as $category) { $query = $this->db->query('SELECT * FROM ' . DB_PREFIX . 'url_alias WHERE `query` = 'category_id=' . (int)$category . '); if ($query->num_rows) { $url .= '/' . $query->row['keyword']; } } unset($data[$key]); } else { $query = $this->db->query('SELECT * FROM ' . DB_PREFIX . 'url_alias WHERE `query` = '' . $this->db->escape($data['route']) . '); if ($query->num_rows) { $url .= '/' . $query->row['keyword']; unset($data[$key]); } } } } $link = str_replace('index.php?route=', '', $link); if ($url) { unset($data['route']); $query = ''; if ($data) { foreach ($data as $key => $value) { $query .= '&' . $key . '=' . $value; } if ($query) { $query = '?' . trim($query, '&'); } } return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query; } else { return $link; } } else { return $link; } } //**** }
Комментарии
Оставить комментарий
Выполнение скриптов на стороне сервера PHP (LAMP) NodeJS (Backend)
Термины: Выполнение скриптов на стороне сервера PHP (LAMP) NodeJS (Backend)