Error 404 when I've added `$link = str_replace('index.php?route=', '', $link);` in seo_url.php in OpenCart

StackOverflow https://stackoverflow.com/questions/23645026

質問

I'm removing index.php?route=common/home on the OpenCart URL's. I'm using the latest version of it. I've tried:

$link = str_replace('index.php?route=', '', $link); 

But it directed me to the page:

"Object not found......Error 404".

役に立ちましたか?

解決

i think what you want is a sef url for each default opencart functionality correct? if is this, you can use a plugin, from anung, on official opencart board. The idea is a huge if/elseif with all default routes on "catalog/controller/common/seo_url.php", before checking the request path, like this:

    } elseif ($this->request->get['_route_'] ==  'contato') { 
        $this->request->get['route'] =  'information/contact';
    } elseif ($this->request->get['_route_'] ==  'account') { 
        $this->request->get['route'] =  'account/account';
    } elseif (isset($this->request->get['path'])) {

and then, before checking if ($key == 'path'), you check you routes:

    } elseif (isset($data['route']) && $data['route'] ==   'information/contact') { 
        $url .=  '/contato';
    } elseif (isset($data['route']) && $data['route'] ==   'account/account') { 
        $url .=  '/account'; 
    } elseif ($key == 'path') {

if you want the plugin, you can search it on official opencart board.

他のヒント

The problem You are facing is with the .htaccess file and the rewrite rules defined there. Because the rule is rewriting the URL (when SEO URLs are turned on) like

http://store.com/some-category/some-sub-category/some-product

into URL like

http://store.com/index.php?_route_=some-category/some-sub-category/some-product

This is meant for SEO URLs. If You are trying to create Your own SEO URLs You'd need to also modify the rewrite rules, e.g. from

RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

into

RewriteRule ^([^?]*) index.php?route=$1 [L,QSA]

(didn't test this one)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top