htaccess URL 重写设置 none SEO url
htaccess URL rewrite to set none SEO url
我需要向 opencart 中的 none seo url 发送请求。
例如:
https://xxxxxxx.yyy.zz/index.php?search=apple
<-- 第一个 Url
这不会加载搜索页面
但是 noe SEO url 将加载如下搜索页面
https://xxxxxxx.yyy.zz/index.php?route=product/search&search=apple
<-- 第二个 Url
如何将第一个 Url 重定向到第二个 Url?
如果您想通过 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));
}
我需要向 opencart 中的 none seo url 发送请求。
例如:
https://xxxxxxx.yyy.zz/index.php?search=apple
<-- 第一个 Url
这不会加载搜索页面 但是 noe SEO url 将加载如下搜索页面
https://xxxxxxx.yyy.zz/index.php?route=product/search&search=apple
<-- 第二个 Url
如何将第一个 Url 重定向到第二个 Url?
如果您想通过 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));
}