Search code examples
phpopencart-3

OpenCart 3 SEO URLs not working correctly


Seems like it's not a rare issue, yet I couldn't find a proper solution for it.

My assumption is that since there is the SEO URLs core module it should do the work without any additional modules or .htaccess edits. But after I enable SEO URLs in System/Settings/Server not all of my URLs are SEO. Some of them change to SEO, but others still look like index.php?route=account/register, index.php?route=information/contact, index.php?route=product/product&path=57&product_id=49 etc.

What should I do to fix this?


Solution

  • There are two methods to fix this problem in Opencart 3x.

    First Method

    1. Go to design/SEO URL
    2. Click on Add new
    3. In Query add account/register or information/contact or route path or product/category id.
    4. Enter the Keyword (should be unique)
    5. Select store and language and save it.

    Second Method

    Please Use anyone Free Extension from the following...

    1. SEO URL issue fix in Opencart 3.x By Sainent
    2. Seo Friendly Urls
    3. SEO_URL remove common/home,information/contact ... index.php
    4. Opencart Seo All Links

    To remove the common/home you need to change the following files

    Open seo_url.php from catalog/controller/startup.

    find

    } elseif ($key == 'path') {
    

    and replace with

     } elseif ($key == 'route') {
     $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
    if ($query->num_rows && $query->row['keyword']) {
    $url .= '/' . $query->row['keyword'];
    unset($data[$key]);
    } else if ($data['route'] == "common/home") { 
    $url .= '/'; 
    } 
    
    } elseif ($key == 'path') {
    

    Hope this Answer might Help you