I need to send request to a none seo url in opencart.
Ex : https://xxxxxxx.yyy.zz/index.php?search=apple
<-- 1st Url
This will not load the Search page But the noe SEO url will load the search page like below
https://xxxxxxx.yyy.zz/index.php?route=product/search&search=apple
<-- 2nd Url
How to redirect 1st Url to 2nd Url ?
If you want to do it via php and inside OpenCart framework, you can do it this way:
In catalog\\controller\\common\\header.php
Find:
public function index() {
Add after it:
// 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));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.