Remove /en/gb/catalog from the url
Posted: Thu Feb 16, 2023 9:55 pm
I've noticed with opencart 4 it's now adding /en-gb/catalog/ to the url.
I can't have this on my clients site as I'm upgrading from opencart 2 and they have spent a ton of time and money on SEO. So ideally I need to remove these 2 directories from the displayed url and also I need the site to work without them.
Plus 'catalog' is US spelling and my client is in the UK (spelled catalogue)
It's not a multi-language site so entering the address without /en-gb does work but I can't get it removed from the displayed url. I've gone through a load of solutions on stackoverflow as well as here, nothing has really worked.
I know I need to create a RewriteRule in the .htaccess but nothing i've found seems to work.
Does anyone have a definitive solution for this?
I'm guessing it needs to do 2 things:
1. make sure https://www.website.com/categories works as it did with opencart 2
2. remove /en-gb/catalog from the displayed url.
Below is my generated .htacess so far:
## SEO URL Settings
RewriteEngine On
## If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
## Rewrite Rules
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|webp|js|css|svg)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{REQUEST_URI} !(.*)en-gb
RewriteRule ^en-gb/(.*)$ /$1 [L,NC,R=301]
RewriteRule ^catalog/(.*)$ /$1 [L,NC,R=301]
I can't have this on my clients site as I'm upgrading from opencart 2 and they have spent a ton of time and money on SEO. So ideally I need to remove these 2 directories from the displayed url and also I need the site to work without them.
Plus 'catalog' is US spelling and my client is in the UK (spelled catalogue)
It's not a multi-language site so entering the address without /en-gb does work but I can't get it removed from the displayed url. I've gone through a load of solutions on stackoverflow as well as here, nothing has really worked.
I know I need to create a RewriteRule in the .htaccess but nothing i've found seems to work.
Does anyone have a definitive solution for this?
I'm guessing it needs to do 2 things:
1. make sure https://www.website.com/categories works as it did with opencart 2
2. remove /en-gb/catalog from the displayed url.
Below is my generated .htacess so far:
## SEO URL Settings
RewriteEngine On
## If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
## Rewrite Rules
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|webp|js|css|svg)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{REQUEST_URI} !(.*)en-gb
RewriteRule ^en-gb/(.*)$ /$1 [L,NC,R=301]
RewriteRule ^catalog/(.*)$ /$1 [L,NC,R=301]