Home Opencart How to remove en-gb from the SEO URL of Opencart 4?

How to remove en-gb from the SEO URL of Opencart 4?

In Opencart 4, when we activate the SEO URL it contains the language as well and for the English language, it shows en-gb by default, which we don’t like so we looked to remove it and the easiest way to remove en-gb is by following code. The following code will not work if you have multiple languages, it works only for English because we are replacing en-gb from the URL, we will find a way soon to remove all the languages and post the solution here.

SEO best practices for Opencart 4

Open file /system/library/url.php and find the following code:

if (!$js) {
	return str_replace('&', '&', $url);
} else {
	return $url;
}

And, replace with the following code:

if (!$js) {
	return str_replace('en-gb/', '', str_replace('&', '&', $url));
} else {
	return str_replace('en-gb/', '',$url);
}

Speed up the Opencart 

This will remove the en-gb from the Opencart 4 URL. Please let us know if you have any questions or suggestions, please subscribe to our YouTube Channel for Opencart video tutorials and you can see more in the Opencart tutorial category. You can also find us on Twitter and Facebook. Enjoy!

1 COMMENT

  1. Dear OC Expert,

    I really hope you can help me.
    I am using OC Version 4.0.2.1.
    using Journal theme

    I have enabled SEO URLs in System>Settings>Store>Server>Use SEO URLs
    I have renamed .htaccess and RewriteEngine is ON

    I do NOT have ‘en-gb’, ‘information’, ‘manufacturers’, ‘product’ or categories or any other keywords in Design>SEO URL

    My site is not showing SEO-friendly URLs, it keeps showing me
    mysite.com/my-product?route=product/product&language=en-gb

    When adding ‘en-gb’ to Design>SEO URL it makes the SEO URL work but the page redirects back to the home page for all categories, information pages, products, and manufacturers. (but shows /en-gb/ in the path which I do not want)

    I simply want clean URLs like

    mysite.com/product
    mysite.com/category
    mysite.com/information-page
    mysite.com/manufacturer

    Thank you in advance for your help.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exit mobile version