htaccess URL重写设置无SEO网址

时间:2017-12-13 08:03:39

标签: php apache .htaccess mod-rewrite opencart

我需要在opencart中向无seo url发送请求。

Ex: https://xxxxxxx.yyy.zz/index.php?search=apple< - 1st Url

这不会加载“搜索”页面 但是noe SEO url会加载搜索页面,如下所示

https://xxxxxxx.yyy.zz/index.php?route=product/search&search=apple

< - 2nd Url

如何将第一个网址重定向到第二个网址?

1 个答案:

答案 0 :(得分:0)

如果你想通过php和OpenCart框架内部来做,你可以这样做:

catalog\controller\common\header.php

<强>查找

public function index() {

在其后添加:

// Get url parameters
$get = $this->request->get;

// Get current route
$route = isset($get['route']) ? $get['route'] : '';

// If the Search parameter is available in the url, but the current page is not the search page
if(isset($get['search']) && $route != 'product/search'){
    // Redirect user to the search page with search keyword
    $this->response->redirect($this->url->link('product/search', 'search=' . $this->request->get['search'], true));
}