Post by chongshengdz » Tue Oct 14, 2014 10:02 pm

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

https://www.transistorfet.com/
https://www.transistormosfet.com/


New member

Posts

Joined
Sat Apr 12, 2014 10:18 pm


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by chongshengdz » Sun Oct 19, 2014 9:53 pm

Do you have a working demo site for it?
It seems your demo site does not work.

https://www.transistorfet.com/
https://www.transistormosfet.com/


New member

Posts

Joined
Sat Apr 12, 2014 10:18 pm


Post by surfdog » Thu Oct 30, 2014 1:22 am

when will this extension be made available for version 2.0? thanks

Newbie

Posts

Joined
Thu Oct 30, 2014 1:21 am

Post by surfdog » Thu Oct 30, 2014 1:23 am

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.
when are you going to be publishing this?

Thanks

Newbie

Posts

Joined
Thu Oct 30, 2014 1:21 am

Post by MarketInSG » Sat Nov 01, 2014 4:57 pm

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


User avatar
Guru Member

Posts

Joined
Wed Nov 16, 2011 11:53 am
Location - Singapore

Post by virgotch » Sat Nov 01, 2014 8:00 pm

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:

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;
}
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:

Code: Select all

parse_str($url_info['query'], $data);
With this one:

Code: Select all

if (isset($url_info['query'])) parse_str($url_info['query'], $data);

New member

Posts

Joined
Sun Oct 26, 2014 4:10 am
Who is online

Users browsing this forum: No registered users and 3 guests