Post by round3455 » Wed Dec 29, 2021 3:24 pm

How to rewrite the URL for my search page in opencart. Current URL is:

Code: Select all

http://IP/opencart/index.php?route=product/search&filter_name=24
But I need to display it like:

Code: Select all

http://localhost/opencart/product/search/42
or in any URL format that is an user friendly. I have tried this:

Code: Select all

RewriteEngine On
RewriteBase /opencart
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

RewriteBase /opencart 
RewriteRule ^search$ index.php?route=product/search  [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/search$
RewriteRule ^([^?]*) index.php?route=$1 [L,QSA]

Newbie

Posts

Joined
Wed Dec 29, 2021 3:19 pm

Post by rjcalifornia » Thu Dec 30, 2021 1:47 am


Image
A2 Hosting features: Shared Turbo Boost, Managed Warp 1, Unmanaged Hyper 1, and Warp 2 Turbo


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide

Post by hpwebdesign » Fri Jan 14, 2022 8:52 am

You can create an SEO URL for product search in the design menu > SEO url

Image


And change the url here according to the SEO url that has been created
Image
Image

For automatic redirects, you can try the method at this link
https://stackoverflow.com/questions/477 ... ne-seo-url

Unfortunately I haven't found one for using htaccess

Attachments

2022-01-14.png

2022-01-14.png (49.09 KiB) Viewed 1186 times

2022-01-14_1.png

catalog/view/javascript/common.js - 2022-01-14_1.png (48.72 KiB) Viewed 1186 times

2022-01-14_2.png

catalog/view/theme/default/template/product/search.twig - 2022-01-14_2.png (60.1 KiB) Viewed 1186 times


HP Web Design
http://hpwebdesign.io
Opencart Extension Development | OpenCart Professional Services | OpenCart Tutorials


User avatar
New member

Posts

Joined
Wed Aug 15, 2018 6:58 am
Location - Yogyakarta

Post by JNeuhoff » Fri Jan 14, 2022 8:29 pm

For certain URLs there is no point in using so-called SEO URLs. Pages based on route=checkout/*, route=account/*, route=product/search, etc shouldn't be indexed by search engines. They can be excluded via your robots.txt. E.g. something like this:

Code: Select all

Disallow: /*?route=checkout/
Disallow: /*&route=checkout/
Disallow: /*?route=account/
Disallow: /*&route=account/
Disallow: /*?route=product/search
Disallow: /*&route=product/search
Disallow: /*?route=product/product/review
Disallow: /*&route=product/product/review
Disallow: /*?route=information/information/agree
Disallow: /*&route=information/information/agree

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by ADD Creative » Fri Jan 14, 2022 9:06 pm

JNeuhoff wrote:
Fri Jan 14, 2022 8:29 pm
For certain URLs there is no point in using so-called SEO URLs. Pages based on route=checkout/*, route=account/*, route=product/search, etc shouldn't be indexed by search engines. They can be excluded via your robots.txt. E.g. something like this:

Code: Select all

Disallow: /*?route=checkout/
Disallow: /*&route=checkout/
Disallow: /*?route=account/
Disallow: /*&route=account/
Disallow: /*?route=product/search
Disallow: /*&route=product/search
Disallow: /*?route=product/product/review
Disallow: /*&route=product/product/review
Disallow: /*?route=information/information/agree
Disallow: /*&route=information/information/agree
Be careful using robots.txt to control indexing, especially for Google. It doesn't stop indexing just crawling. I've seen large sites where this has been done and it just causes loads of pages with no descriptions in the search results.

Google have a big warning about this.
https://developers.google.com/search/do ... bots/intro

You can see the affect by doing a Google search with something like "site:mhccorp.com inurl:checkout" or "site:mhccorp.com inurl:account". The page are still indexed, but with just "No information is available for this page.".

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by JNeuhoff » Fri Jan 14, 2022 9:34 pm

You are right, it often makes sense to combine it with other measures, such as a noindex tag on the actual account or checkout pages.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 123 guests