Post by Jaap » Wed Jun 19, 2024 10:06 pm

SEO friendly URL's are not working on a fresh install.
OC: 3.0.3.9
Steps done:

* changed backend settings to use SEO url's
* Renamed .htaccess.text to .htaccess(chmod 664)
Mod rewrite is enabled ( there's another shop running on the same server without problems)

URL: https://lintenwinkel.nl/
Extension: Export/Import Tool (V4.17) for OpenCart 3.x

Anybody has a solution?

User avatar
Active Member

Posts

Joined
Fri Apr 15, 2011 12:10 am
Location - the Netherlands

Post by JNeuhoff » Wed Jun 19, 2024 10:47 pm

Have you actually enabled SEO Urls in the System > Settings > edit > tab Server > Use SEO URLs ?

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Jaap » Thu Jun 20, 2024 1:22 am

* changed backend settings to use SEO url's
Yes I did, installed many shops.
Never faced this problem.

User avatar
Active Member

Posts

Joined
Fri Apr 15, 2011 12:10 am
Location - the Netherlands

Post by paulfeakins » Thu Jun 20, 2024 7:24 pm

Jaap wrote:
Wed Jun 19, 2024 10:06 pm
* Renamed .htaccess.text to .htaccess(chmod 664)
664 or 644?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Jaap » Thu Jun 20, 2024 7:43 pm

644 Indeed. type mistake.

I can access the friendly URL direct: https://lintenwinkel.nl/satijn-lint-6-mm
But in the navigation it doesn't work

User avatar
Active Member

Posts

Joined
Fri Apr 15, 2011 12:10 am
Location - the Netherlands

Post by ADD Creative » Thu Jun 20, 2024 11:48 pm

Check the value of config_seo_url in your oc_setting table in your database and also check if there are any duplicates.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Jaap » Fri Jun 21, 2024 7:17 pm

Looks OK to me
store_id 0
value 1

config_seo_url has no duplicates

User avatar
Active Member

Posts

Joined
Fri Apr 15, 2011 12:10 am
Location - the Netherlands

Post by JNeuhoff » Fri Jun 21, 2024 7:25 pm

Check your catalog/controller/startup/seo_url.php, to make sure its rewrite function hasn't been modified or tampered with.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by nonnedelectari » Fri Jun 21, 2024 10:55 pm

Are you sure your (default) language is set correctly?

New member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by Jaap » Sat Jun 22, 2024 2:17 am

The file looks (644) untouched

Code: Select all

<?php
class ControllerStartupSeoUrl extends Controller {
    public function index(): void {
        // Add rewrite to url class
        if ($this->config->get('config_seo_url')) {
            $this->url->addRewrite($this);
        }

        // Decode URL
        if (isset($this->request->get['_route_'])) {
            $parts = explode('/', $this->request->get['_route_']);

            // remove any empty arrays from trailing
            if (oc_strlen(end($parts)) == 0) {
                array_pop($parts);
            }

            foreach ($parts as $part) {
                $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE `keyword` = '" . $this->db->escape($part) . "' AND `store_id` = '" . (int)$this->config->get('config_store_id') . "'");

                if ($query->num_rows) {
                    $url = explode('=', $query->row['query']);

                    if ($url[0] == 'product_id') {
                        $this->request->get['product_id'] = $url[1];
                    }

                    if ($url[0] == 'category_id') {
                        if (!isset($this->request->get['path'])) {
                            $this->request->get['path'] = $url[1];
                        } else {
                            $this->request->get['path'] .= '_' . $url[1];
                        }
                    }

                    if ($url[0] == 'manufacturer_id') {
                        $this->request->get['manufacturer_id'] = $url[1];
                    }

                    if ($url[0] == 'information_id') {
                        $this->request->get['information_id'] = $url[1];
                    }

                    if ($query->row['query'] && $url[0] != 'information_id' && $url[0] != 'manufacturer_id' && $url[0] != 'category_id' && $url[0] != 'product_id') {
                        $this->request->get['route'] = $query->row['query'];
                    }
                } else {
                    $this->request->get['route'] = 'error/not_found';
                    break;
                }
            }

            if (!isset($this->request->get['route'])) {
                if (isset($this->request->get['product_id'])) {
                    $this->request->get['route'] = 'product/product';
                } elseif (isset($this->request->get['path'])) {
                    $this->request->get['route'] = 'product/category';
                } elseif (isset($this->request->get['manufacturer_id'])) {
                    $this->request->get['route'] = 'product/manufacturer/info';
                } elseif (isset($this->request->get['information_id'])) {
                    $this->request->get['route'] = 'information/information';
                }
            }
        }
    }

    public function rewrite($link) {
        $url = '';
        $data = [];
        $url_info = parse_url(str_replace('&amp;', '&', $link));

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

        foreach ($data as $key => $value) {
            if (isset($data['route'])) {
                if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
                    $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE `query` = '" . $this->db->escape($key . '=' . (int)$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]);
                    }
                } elseif ($key == 'path') {
                    $categories = explode('_', $value);

                    foreach ($categories as $category) {
                        $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE `query` = 'category_id=" . (int)$category . "' 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'];
                        } else {
                            $url = '';
                            break;
                        }
                    }

                    unset($data[$key]);
                }
            }
        }

        if ($url) {
            unset($data['route']);

            $query = '';

            if ($data) {
                foreach ($data as $key => $value) {
                    $query .= '&' . rawurlencode((string)$key) . '=' . rawurlencode((is_array($value) ? http_build_query($value) : (string)$value));
                }

                if ($query) {
                    $query = '?' . str_replace('&', '&amp;', trim($query, '&'));
                }
            }

            return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query;
        } else {
            return $link;
        }
    }
}

User avatar
Active Member

Posts

Joined
Fri Apr 15, 2011 12:10 am
Location - the Netherlands

Post by Jaap » Sat Jun 22, 2024 2:20 am

Will delete all, and install again.
See if it solves the issue.
Will let you know.
Thanks so far for all the help

User avatar
Active Member

Posts

Joined
Fri Apr 15, 2011 12:10 am
Location - the Netherlands

Post by nonnedelectari » Sat Jun 22, 2024 8:08 pm

Jaap wrote:
Sat Jun 22, 2024 2:20 am
Will delete all, and install again.
See if it solves the issue.
Will let you know.
Thanks so far for all the help
I was asking :
"Are you sure your (default) language is set correctly?"
because you are not setting a language cookie (just currency and session) and seo url rewrite is language dependent.

New member

Posts

Joined
Thu Mar 04, 2021 6:34 pm
Who is online

Users browsing this forum: mauprik and 21 guests