How to rewrite index.php?route to seo friendly urls for opencart 2.0?
for example:
from index.php?route=product/search&search=keyword to search&search=keyword
for example:
from index.php?route=product/search&search=keyword to search&search=keyword
Electronic Components: integrated circuits, ic, semiconductors, transistors, thyristors, fuses, resistors, diodes, capacitors & more.
buy & sell transistors & mosfet
you can consider this: http://www.opencart.com/index.php?route ... n_id=12422
It's ready for 2.0 use, but we have not publish the update.
It's ready for 2.0 use, but we have not publish the update.
Do you have a working demo site for it?
It seems your demo site does not work.
It seems your demo site does not work.
Electronic Components: integrated circuits, ic, semiconductors, transistors, thyristors, fuses, resistors, diodes, capacitors & more.
buy & sell transistors & mosfet
when are you going to be publishing this?MarketInSG wrote:you can consider this: http://www.opencart.com/index.php?route ... n_id=12422
It's ready for 2.0 use, but we have not publish the update.
Thanks
you can drop us a support ticket for you to send the pre released files. We're occupied with updating the last few mods and haven't got time to push the updated mods
you can try to edit this code for 2.0 , this code worked for 1.5
Go to /system/library/url.php and look at the public function link. Replace the function with this version:
run some tests and if the SEO URLs are enabled, it becomes necessary to make one single edit in the /catalog/controller/common/seo_url.php to avoid an "Undefined index" error.
nside public function rewrite, replace this line:
With this one:
Go to /system/library/url.php and look at the public function link. Replace the function with this version:
Code: Select all
public function link($route, $args = '', $connection = 'NONSSL') {
if ('NONSSL' == $connection) {
$url = $this->url;
} else {
$url = $this->ssl;
}
if ('common/home' == $route) {
if ($args) {
$url .= '?' . str_replace('&', '&', '&' . ltrim($args, '&'));
}
} else {
$url .= 'index.php?route=' . $route;
if ($args) {
$url .= str_replace('&', '&', '&' . ltrim($args, '&'));
}
}
foreach ($this->rewrite as $rewrite) {
$url = $rewrite->rewrite($url);
}
return $url;
}
nside public function rewrite, replace this line:
Code: Select all
parse_str($url_info['query'], $data);
Code: Select all
if (isset($url_info['query'])) parse_str($url_info['query'], $data);
Thank you for the solution.
I have OC 2.0.1.1 tested the above code:
i have only edit in the /catalog/controller/common/seo_url.php
replacing with:
And the page loads:
https://www.dbkdimitrov.com/search&search=audi
but can't add the rewrite rule like the bottom:
I have OC 2.0.1.1 tested the above code:
i have only edit in the /catalog/controller/common/seo_url.php
replacing with:
Code: Select all
if (isset($url_info['query'])) parse_str($url_info['query'], $data);
https://www.dbkdimitrov.com/search&search=audi
but can't add the rewrite rule like the bottom:
Code: Select all
<file path="catalog/controller/common/seo_url.php">
<operation>
<search>
<![CDATA[
class ControllerCommonSeoUrl extends Controller {
]]>
</search>
<add position="after">
<![CDATA[
private $url_list = array (
'common/home' => '',
'account/wishlist' => 'whishlist',
'account/account' => 'account',
'account/edit' => 'account/edit',
'account/password' => 'account/password',
'account/address' => 'account/address',
'account/address/edit' => 'account/address/edit',
'account/reward' => 'account/reward',
'account/login' => 'account/login',
'account/logout' => 'account/logout',
'account/order' => 'account/order',
'account/order/info' => 'account/order/info',
'account/newsletter' => 'account/newsletter',
'account/forgotten' => 'account/forgot',
'account/download' => 'account/download',
'account/return' => 'account/return',
'account/return/add' => 'account/return/add',
'account/transaction' => 'account/transaction',
'account/register' => 'account/register',
'account/recurring' => 'account/recurring',
'account/voucher' => 'account/voucher',
'affiliate/account' => 'affiliate',
'affiliate/edit' => 'affiliate/account',
'affiliate/password' => 'affiliate/password',
'affiliate/payment' => 'affiliate/payment',
'affiliate/tracking' => 'affiliate/tracking',
'affiliate/transaction' => 'affiliate/transaction',
'affiliate/logout' => 'affiliate/logout',
'affiliate/forgotten' => 'affiliate/forgotten',
'affiliate/register' => 'affiliate/register',
'affiliate/login' => 'affiliate/login',
'checkout/cart' => 'cart',
'checkout/checkout' => 'checkout',
'checkout/voucher' => 'voucher',
'checkout/success' => 'success',
'information/contact' => 'contact',
'information/ofer' => 'ofer',
'information/sitemap' => 'sitemap',
'product/special' => 'special',
'product/manufacturer' => 'manufacturer',
'product/compare' => 'compare',
'product/search' => 'search',
'product/search&search' => 'search&search', // this doesn't work! please help!
);
]]>
</add>
</operation>
<operation>
<search>
<![CDATA[
$this->request->get['route'] = 'error/not_found';
]]>
</search>
<add position="after" offset="4">
<![CDATA[
if ( $_s = $this->setURL($this->request->get['_route_']) ) {
$this->request->get['route'] = $_s;
}
]]>
</add>
</operation>
<operation>
<search>
<![CDATA[
if ($url) {
]]>
</search>
<add position="before" offset="3">
<![CDATA[
if( $_u = $this->getURL($data['route']) ){
$url .= $_u;
unset($data[$key]);
}
]]>
</add>
</operation>
<operation>
<search>
<![CDATA[
return $link;
]]>
</search>
<add position="after" offset="2">
<![CDATA[
public function getURL($route) {
if( count($this->url_list) > 0) {
foreach ($this->url_list as $key => $value) {
if($route == $key) {
return '/'.$value;
}
}
}
return false;
}
public function setURL($_route) {
if( count($this->url_list) > 0 ){
foreach ($this->url_list as $key => $value) {
if($_route == $value) {
return $key;
}
}
}
return false;
}
]]>
</add>
</operation>
</file>
https://www.dbkdimitrov.com
https://www.tuningcenterbg.com
https://www.samozamen.com
https://www.h-r.bg
Who is online
Users browsing this forum: No registered users and 50 guests