Page 1 of 1
Add SEO URL for search page
Posted: Tue Jul 17, 2018 6:57 pm
by dswtpl
Trying to find SEO friendly URL for the search page. I tried the following code in .htaccess file.
RewriteRule ^search/([^/]*)$ index.php?route=product/search&search=%{QUERY_STRING} [L]
And
catalog/controller/startup/seo_url.php:
} elseif ($data['route'] == 'product/search' && $key == 'tag') {
$url .= '/tags/' . str_replace(' ','-',$value);
unset($data[$key]);
} elseif ($data['route'] == 'product/search' && $key !== 'tag') {
$url .= '/search/' . str_replace(' ','-',$value);
unset($data[$key]);
//....
Is there any way to rewrite routes without choosing one or the other?
Using Opencart 2.3.0
Re: Add SEO URL for search page
Posted: Tue Jul 17, 2018 10:23 pm
by thekrotek
If you don't want not use any extension, which adds a custom SEO URL functionality, you can try to insert query/keyword pair into url_alias table.
Re: Add SEO URL for search page
Posted: Tue Jul 17, 2018 11:12 pm
by Johnathan
thekrotek wrote: ↑Tue Jul 17, 2018 10:23 pm
If you don't want not use any extension, which adds a custom SEO URL functionality, you can try to insert query/keyword pair into url_alias table.
That doesn't work, unfortunately. The built-in SEO system for OpenCart only affects product, category, manufacturer, and information pages. You can't rewrite other URLs just by inserting the data into the "url_alias" table, though hopefully that will be possible in a future version. (Especially given how common this type of question is.)
Re: Add SEO URL for search page
Posted: Wed Jul 18, 2018 12:05 am
by thekrotek
Johnathan wrote: ↑Tue Jul 17, 2018 11:12 pm
That doesn't work, unfortunately. The built-in SEO system for OpenCart only affects product, category, manufacturer, and information pages. You can't rewrite other URLs just by inserting the data into the "url_alias" table, though hopefully that will be possible in a future version. (Especially given how common this type of question is.)
I know very well, how it works, I have my own SEO extension. Since the guy already managed to find out, where to edit the script, I gave him a tip about database. Hopefully, it will be enough for him.
Re: Add SEO URL for search page
Posted: Wed Jul 18, 2018 6:23 pm
by dswtpl
thekrotek wrote: ↑Tue Jul 17, 2018 10:23 pm
If you don't want not use any extension, which adds a custom SEO URL functionality, you can try to insert query/keyword pair into url_alias table.
If I can add keyword directly to table then we compulsory need to coding in seo_url.php file. Without adding this file SEO URL is not working.