Page 1 of 1

How to rewrite index.php?route to seo friendly urls?

Posted: Tue Oct 14, 2014 10:02 pm
by chongshengdz
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

Re: How to rewrite index.php?route to seo friendly urls?

Posted: Thu Oct 16, 2014 9:53 pm
by MarketInSG
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.

Re: How to rewrite index.php?route to seo friendly urls?

Posted: Sun Oct 19, 2014 9:53 pm
by chongshengdz
Do you have a working demo site for it?
It seems your demo site does not work.

Re: How to rewrite index.php?route to seo friendly urls?

Posted: Thu Oct 30, 2014 1:22 am
by surfdog
when will this extension be made available for version 2.0? thanks

Re: How to rewrite index.php?route to seo friendly urls?

Posted: Thu Oct 30, 2014 1:23 am
by surfdog
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

Re: How to rewrite index.php?route to seo friendly urls?

Posted: Sat Nov 01, 2014 4:57 pm
by MarketInSG
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

Re: How to rewrite index.php?route to seo friendly urls?

Posted: Sat Nov 01, 2014 8:00 pm
by virgotch
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);