How can I remove route= from all links on OpenCart 3.0?

Member

by mabelle , in category: SEO , a year ago

How can I remove route= from all links on OpenCart 3.0?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

3 answers

by priscilla.langworth , a year ago

@mabelle 

To remove the "route=" parameter from all links on OpenCart 3.0, you can follow these steps:

  1. Open your OpenCart installation folder and navigate to the catalog/controller/startup/seo_url.php file.
  2. Find the following code in the seo_url.php file:
1
2
3
4
5
if (isset($this->request->get['route'])) {
	$route = $this->request->get['route'];
} else {
	$route = 'common/home';
}


  1. Replace it with the following code:
1
$route = isset($this->request->get['_route_']) ? $this->request->get['_route_'] : 'common/home';


  1. Save the changes and close the file.
  2. Open the catalog/controller/common/seo_url.php file and find the following code:
1
2
3
if (isset($this->request->get['route'])) {
	$url .= '&route=' . $this->request->get['route'];
}


  1. Replace it with the following code:
1
2
3
if (!empty($data['_route_'])) {
	$url .= '/' . $data['_route_'];
}


  1. Save the changes and close the file.


After following these steps, the "route=" parameter should be removed from all links on your OpenCart 3.0 store.

by declan_ritchie , 3 months ago

@mabelle 

Please be cautious when modifying code files, as any incorrectly made changes may lead to issues with your OpenCart installation. Before making any changes, it is recommended to backup your files and database.


Here are the steps to remove the "route=" parameter from all links on OpenCart 3.0:

  1. Open your OpenCart installation folder and navigate to the catalog/controller/common/seo_url.php file.
  2. Find the following line of code: if (isset($this->request->get['route'])) { $url .= '&route=' . $this->request->get['route']; }
  3. Replace it with the following code: if (!empty($data['_route_'])) { $url .= '/' . $data['_route_']; }
  4. Save the changes and close the file.
  5. Clear your OpenCart cache, if applicable.
  6. Test your website to ensure that the "route=" parameter has been removed from all links.


By making these changes, the "route=" parameter will be replaced with the appropriate route value in the URL, resulting in cleaner links without the "route=" parameter.

by kyleigh.wolff , 2 months ago

@mabelle 

Before making any changes to your OpenCart installation files, it is recommended to create a backup of your website.


To remove the "route=" parameter from all links in OpenCart 3.0, follow these steps:

  1. Open your OpenCart installation folder and navigate to the system/library/url.php file.
  2. Find the following function within the file:
1
2
3
4
public function link($route, $args = '', $secure = false)
{
    // ...
}


  1. Inside the link function, locate the following line of code:
1
2
3
if ($args) {
    $url .= '&' . ltrim($args, '&');
}


  1. Replace the above line with the following code:
1
2
3
if ($args) {
    $url .= '/' . ltrim($args, '/');
}


  1. Save the changes and close the file.


This change will modify the URL generation process in OpenCart, replacing the & symbol with a / in the generated URLs. As a result, the "route=" parameter will be removed from all links.


After making these changes, clear your OpenCart cache and test your website to ensure that the "route=" parameter has been removed from all links.