How can I create custom SEO-friendly URLs in OpenCart?

前端 未结 8 1640
天命终不由人
天命终不由人 2020-11-30 22:29

How can you customize system URLs in OpenCart? For example, I would like http://example.com/index.php?route=checkout/cart to be displayed as http://example.com/cart

相关标签:
8条回答
  • 2020-11-30 23:20

    Depending on the level of customization you need, there are a few extensions available, including free ones.

    This one works both on OpenCart 1.5 and OpenCart 2 and seems quite customizable. However it does not support customization of hardcoded URL parts like "checkout/cart" or "account/wishlist".

    Here is a vQmod for OpenCart 2.0 (might work with 1.5, not tested) which applies to the forementioned extension and allows to change these hardcoded strings into whatever you want, and support multilanguage websites.

    E.g. "checkout/cart" will become "cart" for English, "panier" for French, etc.

    0 讨论(0)
  • 2020-11-30 23:21

    vQmod xml file

    <modification>
    <id>Seo All Alias</id>
    <version>1.0</version>
    <vqmver>2.1.7</vqmver>
    <author>noname</author>
    <file name="catalog/controller/common/seo_url.php"> 
        <operation>
            <search position="after" offset="2"><![CDATA[
                $this->request->get['route'] = 'information/information';
            ]]></search>
            <add><![CDATA[
            else {
                $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($this->request->get['_route_']) . "'");
                if ($query->num_rows) {
                    $this->request->get['route'] = $query->row['query'];
                }
            }
            ]]></add>
        </operation>
    
        <operation>
            <search position="after" offset="1" index="2"><![CDATA[
                unset($data[$key]);
            ]]></search>
            <add><![CDATA[
                    else {
                        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($data['route']) . "'");
    
                        if ($query->num_rows) {
                            $url .= '/' . $query->row['keyword'];
                            unset($data[$key]);
                        }
                    }
            ]]></add>
        </operation>
    
    </file>
    

    0 讨论(0)
提交回复
热议问题