Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[CONTRIBUTION] Ultimate SEO URLs v2.1 - by Chemo


Recommended Posts

Add the redirect above the redirects for this addon and let the code sort it out.

redirect 301 /product-p-800.html https://www.site.com/product_info.php?products_id=900 

 

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@Jack_mcs

11 hours ago, Jack_mcs said:

Add the redirect above the redirects for this addon and let the code sort it out.


redirect 301 /product-p-800.html https://www.site.com/product_info.php?products_id=900 

 

I tried the above(with my site details) but it goes to a page not found.. i tried turning off your header redirect still goes to stock page not found.. reset seo cache still page not found.. It is ignoring the 301... weird

Link to comment
Share on other sites

Please ignore the post above

@Jack_mcs

solution

12 hours ago, Jack_mcs said:

Add the redirect above the redirects for this addon and let the code sort it out.


redirect 301 /product-p-800.html https://www.site.com/product_info.php?products_id=900 

 

is absolutely right. I made a mistake with the URL.

Thanks all for your help

Link to comment
Share on other sites

hello support,

i am using frozen 2341CE, with php 7.1.

trying to install oscom-ultimate-seo-urls-36rDo-CPS2y.

in the instructions it states to find this in: STEP #4 - Edit admin/categories.php

  ////
// Ultimate SEO URLs v2.2d
// The HTML href link wrapper function
 function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
   global $seo_urls;                
   if ( !is_object($seo_urls) ){
    if ( !class_exists('SEO_URL') ){
     include_once('includes/classes/seo.class.php');
    }
    global $languages_id;
    $seo_urls = new SEO_URL($languages_id);
   }
   return $seo_urls->href_link($page, $parameters, $connection, $add_session_id);
 }

and add after:

// Ultimate SEO URLs v2.2d
// If the action will affect the cache entries
   if ( preg_match("/(insert|update|setflag)/i", $action) ) include_once('includes/reset_seo_cache.php');

searching for pieces of the code or searching the whole site  for wrapper function I can not find something resembling

the code so 

where do i put the new suggested code???

Z

Link to comment
Share on other sites

1 hour ago, zpupster said:

it states to find this in: STEP #4 - Edit admin/categories.php

It looks like you mixed step 4 and 5. Please take another look at the instructions.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 2 weeks later...

Hi there

I found a curious issue when this addon is used with a navbar drop down cart in the header.

The urls of the products in the cart drop down look like this

https://www.site.com.au/-p-700.html

instead of 

https://www.site.com.au/name-of-product/-p-700.html

The code to create the cart in the navbar is standard 

<?php      
      $products = $cart->get_products();
      foreach ($products as $k => $v) {
        echo '<li>' . sprintf(MODULE_NAVBAR_SHOPPING_CART_PRODUCT, $v['id'], $v['quantity'], $v['name']) . '</li>';
      }        
      ?>

and the language file

define('MODULE_NAVBAR_SHOPPING_CART_PRODUCT', '<a href="' . tep_href_link('product_info.php', 'products_id=%s') . '">%s x %s</a>');

Just wondered why this is?

 

 

Edited by bonbec
remove real link
Link to comment
Share on other sites

Try changing the $v['name'] to "test". If test shows up in the url, then the $v['name'] is not set.

Also, to be clear, the url would not have the slash you show so it would be https://www.site.com.au/name-of-product-p-700.html . That was probably a typo but I thought I should mention it.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

9 hours ago, Jack_mcs said:

Try changing the $v['name'] to "test". If test shows up in the url, then the $v['name'] is not set.

Also, to be clear, the url would not have the slash you show so it would be https://www.site.com.au/name-of-product-p-700.html . That was probably a typo but I thought I should mention it.

Hi there

I did as suggested and the name disappeared from the drop down and was not replaced by the word test.

Url was a typo but the link that currently shows is

https://www.site.com.au/-p-700.html

 

Link to comment
Share on other sites

The other question I have is

over the years a few people have linked to the site incorrectly  leaving a white space in the url which becomes %20

is there a way to use htaccess or any other method  to strip out any whitespaces  before any other redirects happen.

The url in question is 

https://www.site.com/product_info?cPath=28&(spaceishere)products_id=1000

Link to comment
Share on other sites

I'm not sure of the precedence order when a sprintf command is used for a function in a language file. I wouldn't code it that way. It might be that the link is being built before the text is added. If all else fails, I would re-code it so there aren't three things going on in one call.

Other than that, the only other thing I can think of is if you are using Header Tags SEO and haven't enabled the option for it in this addon and/or not ran fill tags.

For the url spaces, see this. The code would go before the rewrites for those of this addon.

 

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Thanks so much for this

I re-coded the shopping cart header module using the code from the column box module so avoided sprintf

 public function getOutput() {
      GLOBAL $cart, $currencies, $PHP_SELF;
      
              $cart_contents_string = '';
      if ($cart->count_contents() > 0) {
        $cart_contents_string = NULL;
        $products = $cart->get_products();
        for ($i=0, $n=sizeof($products); $i<$n; $i++) {
          $cart_contents_string .= '<li>';
          $cart_contents_string .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';
          $cart_contents_string .= $products[$i]['quantity'] . '&nbsp;x&nbsp;';
          $cart_contents_string .= $products[$i]['name'];
          $cart_contents_string .= '</a></li>';
        }
      }

and then called 

<?php echo $cart_contents_string; ?>

in the template file

 

 

 

will sort out the htaccess part you have offered when the site is a bit quieter

Link to comment
Share on other sites

The htaccess bit I couldnt get to work.

i placed it above all the other code. It goes to page not working.

could it be this bit as i don't want to add just remove

# replace spaces by - in between
RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1-$2 [L,R]

Link to comment
Share on other sites

The htaccecss file works for urls like

https://www.site.com/name-of-product(accidentalspace)-p-1000.html

but not 

https://www.site.com/product_info?cPath=28&(spaceishere)products_id=1000

I thought it should remove the incorrect space and then the program takes over and redirects to the properly formed url

 

Link to comment
Share on other sites

3 hours ago, douglaswalker said:

The htaccess bit I couldnt get to work.

i placed it above all the other code. It goes to page not working.

could it be this bit as i don't want to add just remove

# replace spaces by - in between
RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1-$2 [L,R]

This replaces space with a hyphen. If you change $1-$2 to $1$2 it would simply strip the space.

Either will work in the section of url that's ignored (before  -p-). Stripping the space is likely what you need for the query string (your example) but around the p 1000 would need the hyphen

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@BrockleyJohn

not sure what i am doing wrong here.

I will go through the steps again and write them here to see if anyone can spot the issue

https://www.site.com.au/product_info.php?cPath=28& &(space here)products_id=71

is a link that google has picked up somewhere on the web. It has a space wrongly placed between cPath=28&(space here) products_id=71

This is creating the page to fail and try to redirect over and over.

It ultimately needs to go to 

https://www.mysite.com.au/product-product--toy-p-71.html

once it has passed through SEO urls program

So I am trying to strip the space out of cPath=28&(space here) products_id=71

using htaccess

RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1$2 [L,R]

then send it on its way.

However the htaccess is not working

 

Link to comment
Share on other sites

@douglaswalker sorry Doug didn't think properly - you need to change the query string rather than the url

RewriteCond %{QUERY_STRING} "^([^\s%20]*)(?:\s|%20)+(.*)$"
RewriteRule ^ %{REQUEST_URI}?%1%2 [L,R]

 

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

  • 3 weeks later...

Need help when I hover over links I don't see the seo friendly urls but when I click them it works and goes there? When I create a sitemap it makes it with dynamic links? Using oscommerce 2.2 rc2 - can't upgrade too many mods installed over the years. Any idea where to look? 

Edited by wflynnnn
Link to comment
Share on other sites

17 minutes ago, wflynnnn said:

Using oscommerce 2.2 rc2

I doubt one of the latest versions of this addon will work for you. Try installing 2.2d-13 or earlier. You'll lose improvements and security fixes but that's the trade-off when running such an old shop.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 3 weeks later...

Hello
Thank you for excusing my english
Oscommerce 2.3.4 / ultimate seo url 2.2d18 / php7

Rewriting Works very well, but I see the robots on the following urls
/my-product-name-p-788.html?products_id=788 (for more products)

For manufacturers too
/my-manufacturer-name-m-32.html?manufacturers_id=32

Is it normal ?

Can someone help me
thank you so much

Osc 2.3.4

mts template

Link to comment
Share on other sites

7 hours ago, ammsimon said:

Rewriting Works very well, but I see the robots on the following urls

I'm not clear as to what you mean by "robots" in this context. Does the actual url  look like your example? The only time I've seen a url like that, that I can recall, was due to improperly coded links in the code. So do all of the url's look like that or just cert ones? And what happens if you turn this addon off? Will the links then work if clicked on?

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...