Post by OpenCode » Fri Sep 01, 2017 4:55 am

Hi everyone we need some help! we are updating some of our products friendly_url... (why?) well because some of our products urls have empty spaces (%20) and some of them got UPPER CASES, well long story short, now that we update their urls remove the empty spaces and make the Upper case to lower case we have a lots of 404 product no found (Not found) from the server respond, even know the product_id still the same,
is there any way to tell crawlers that the page was updated and (I guess move to the new_url).

we already search in the forum incase some already post anything similar but we found none other than using .htaccess but the list of product will be very long and adding one by one it will be time consuming, we were hopping to find something that will do this automatic if the product_id is the same
but the product url has change tell the crawlers that we move the product to this url, (with a 301 redirect to the new url).
we hope this is not to complicated, and we know some of you genius on this matter can help us and in the process help other like us, struggling to make a buck, an keep our site running for time to came...

or OC is and old version 1.5.6.4 ( or 1.5.5.1) if there is no differs we don't know.

Thank You to any one that took the time to read our post any help on this matter will be greatly appreciated.

God Bless OpenCart team for the great work they done.

New member

Posts

Joined
Fri Jun 07, 2013 9:31 am

Post by yodapt » Fri Sep 01, 2017 7:37 pm

You can create an extra DB field for the new SEO urls, then check upon page access if the url is a good or a bad one, if it's a bad one you issue a 301 status and redirect to the correct url. You can also create a routine to check for uppercase and spaces in SEO so you dont have to do it manually.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by OpenCode » Sun Sep 03, 2017 3:30 am

it is good idea but it will add a lot more lines and the query to check the link and return the results will slow down with time.

can any one pint me to the right direction on witch file is handling the url friendly and from there used the product_id to match the results,
because somewhere in the core it has to be a function to handle all request, because before we enable the SEO Friendly on admin all request are pass to search engines as (index.php?route=product/product&product_id=IDNUMBER) so all products used the same link and it is getting the result as "product_id=IDNUMBER" so in our case since we edit the URL the "product_id=IDNUMBER" is the same so we should me able to tell search engines that we move the previous link to this new link and from there do 301 redirect instead of 404,

exp below ( but we really don't know how to do it thats why we need help form experts...

Code: Select all

if($_SERVER["REQUEST_URI"])
{
    case '/old-url': $product_id = "/new-url"; break;
}
if($product_id)
{
    header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $product_id); exit;
}
Thank you

New member

Posts

Joined
Fri Jun 07, 2013 9:31 am

Post by yodapt » Sun Sep 03, 2017 4:44 am

The file you want is catalog/controller/common/seo_url.php

If you dont want to overpopulate the database, you can create a routine to check all product links for spaces and uppercase letters, format the links and save the result in a CSV or something like that, associated with the product ID, and call that file with seo_url.php to try and match the requests.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by victorj » Sun Sep 03, 2017 6:25 pm

There is a smart module that let you redirect any non existing page to any page you like.
It logs all 404 pages and you can assign any url to a non existing page.

https://www.opencart.com/index.php?rout ... load_id=36

Koeltechnische deurrubbers eenvoudig online op maat bestellen.
Alle niet stekplichtige onderdelen zoals scharnieren, sloten, randverwarming en verlichting voor alle typen koelingen en vriezers.
https://koelcel-onderdelen.com

Koeltechnische deurrubbers eenvoudig online op maat bestellen.
Eigen productie en snelle levering.
https://123-deurrubbers.com


User avatar
Expert Member

Posts

Joined
Sat Jun 25, 2011 4:09 am
Location - Alkmaar Holland

Post by OpenCode » Mon Sep 04, 2017 3:31 am

Nice! Thank you to victorj, that works ( not as we expected ) since we have to check the links (404) and add the new link but for now it does the trick.

to yodapt, how can I get the product_id on "seo_url.php" I check the file and there is no variable for $product_id.
so far we got this but because there is no $product_id is not working at all.

Code: Select all

            if (substr(HTTP_SERVER, 0, -1) . $_SERVER['REQUEST_URI'] != $this->url->link('product/product', 'product_id=' . $product_id)) {
            header ('HTTP/1.1 301 Moved Permanently');
            header('Location: '.$this->url->link('product/product', 'product_id=' . $product_id));
            exit;
        }
        
how can we get it to work what are we doing wrong?
can you help us solved...

Thank You

New member

Posts

Joined
Fri Jun 07, 2013 9:31 am

Post by yodapt » Mon Sep 04, 2017 4:30 am

Code: Select all

$this->request->get['product_id']

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by OpenCode » Thu Sep 07, 2017 5:07 am

@ Yodapt.

We make this changes to our code but doesn't seem to work

Code: Select all

            if (substr(HTTP_SERVER, 0, -1) . $_SERVER['REQUEST_URI'] != $this->url->link('product/product', 'product_id=' . 'product_id')) {
            header ('HTTP/1.1 301 Moved Permanently');
            header('Location: '.$this->url->link('product/product', 'product_id=' . 'product_id'));
            exit;
        }
can you help us modifying the code to make work
we really don't know what are we missing ( we are using friendly url) we don't know if we should call get-product_id and compare product_id and get keywords than from there redirect to new url otherwise????.... :?

help us if your can on this issue

Thank you.

New member

Posts

Joined
Fri Jun 07, 2013 9:31 am

Post by yodapt » Thu Sep 07, 2017 7:29 am

You need it done for you, not help with it. If you want, I can do it for you, just contact me.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm

Who is online

Users browsing this forum: Google [Bot] and 73 guests