Jump to content
Chemo

[Contribution] Ultimate SEO URLs - by Chemo

Recommended Posts

Hi.

 

I just installed Ultimate SEO URLs. Its the best contribution that I have installed & the documentation is excellent.

 

But, I have a small problem. Results returned by the advanced search function are not rewritten, breadcrumbs links on product pages arrived at through the advanced search results also not rewritten.

 

You can try it here: www.apexdog.com

 

Server info (Apache on *NIX machine, etc)

Linux 2.4.21-27.0.1.ELsmp

MySQL 4.0.22-standard

4.3.10 (Zend: 1.3.0)

Apache 1.3.33

 

Exact problem

Described above

 

What you've tried to solve it

Make this post

 

...and any debuggin you've done

None, don't know where to start

Share this post


Link to post
Share on other sites

Dan,

 

It can be fixed but adds a layer of complexity to the contribution. See, other SEO URL contributions try to rewrite EVERYTHING for the store. I took a simple approach and only selected the URLs for index.php (categories) and product_info.php (products).

 

IMO, SEO URLs are for search engines / spiders as priority #1. They are also nice for customers for easy to remember addresses but that is an arguable point as to whether they will use them to come back (versus hitting you main domain and working back through).

 

So, my contribution only optimizes the URLs that are absolutely essential for search engines (categories and products) and leaves the rest to the customer. You will NOT have a spider go to the advanced search page, enter search criteria, and then hit the submit button. Only customers will do that...

 

I can add the advanced_search.php URL's to the list of optimized URLs but overall it will make the contribution harder to install (READ: MORE STEPS) and more complex. A general rule is that the more moving parts on something the more places available to break down. I would rather have something that works for its intended purpose without being too bloated, slow, or complex.

 

As it is coded now the functionality is excellent, the ease of install is allows installation by all level of webmasters/store owners, and also is *almost* bullet proof with stability.

 

Bobby

Share this post


Link to post
Share on other sites
I have checked that I have the full filepath to the catalog folder instead of the stock /folder/ in .htaccess, and that the .htaccess file is residing in the catalog directory, but still no joy? Hmmm. Any more ideas would be much appreciated

 

regards

 

Sorry, I may have confused you on this.

RE: .htaccess file

 

# Change "folder" to your catalog directory name

RewriteBase /folder/

 

change that to just

# Change "folder" to your catalog directory name

RewriteBase /catalog/

 

Don't put the full path there.

 

Bobby is saying to use the "full path" in the Admin Configuration screen for the SEO URL's.

 

Paul

Edited by Fourbit

Share this post


Link to post
Share on other sites

hello,

 

i have a little prob with this contrib.

 

i can?t set

Use search-engine urls

to false (second shop, same database)

 

if i dont set the Use search-engine url to false, i dont get products in my shopping cart

 

message:

the requested url was not found

 

thx for your help

mike

Share this post


Link to post
Share on other sites

On the store that you need to disable SEF URLs place this code at the very top of includes/application_top.php:

define('SEARCH_ENGINE_FRIENDLY_URLS', 'false');

The thing to remember is that something can only be defined once. So, when the configuration for that store is pulled and it tries to define it as true it will be disregarded as it is already defined (can't change a defined value).

 

That will turn off SEF URLs for the shop and leave the other store with the value true.

 

Bobby

Share this post


Link to post
Share on other sites
Sorry, I may have confused you on this.

RE: .htaccess file

 

# Change "folder" to your catalog directory name

RewriteBase /folder/

 

change that to just

# Change "folder" to your catalog directory name

RewriteBase /catalog/

 

Don't put the full path there. 

 

Bobby is saying to use the "full path" in the Admin Configuration screen for the SEO URL's.

 

Paul

 

hi, this is how the addition to .htaccess in catalog now looks. This has not made any difference to the problem. That is there are 404 error pages when you click on any category from the home page of the catalog.

 

RewriteBase /catalog/

RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}

RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}

 

I can confirm that the cache file has filled with categories and products, and that the URL appears to be correct according to the naming protocol. Because the URL is correct, I assume the rewrite rule to be working OK.

 

The problem then is in converting the rewritten URL back to the Cid and Pid to call the correct page. How does this work and what can I check?

 

Thanks again

Share this post


Link to post
Share on other sites

The .htaccess code should be like this:

RewriteEngine On 
RewriteBase /catalog/
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}

Notice you need to have the RewriteEngine On before the others...

 

Bobby

Share this post


Link to post
Share on other sites

I agree about the search & breadcrumb issue, it's not that important.

 

I also have this site map contribution installed http://www.oscommerce.com/community/contributions,1529

 

The links in that site map are not rewritten either. I am willing to hack away at it to get the SEF urls in the site map, but I don't have much php experience so I need someone to point me in the right direction.

 

My thoughs are to leave most of the site map code as is, but instead of displaying the product name & model with Link, put that all into a variable or array so it can be reformatted & displayed with a SEF link.

 

This is the code that displays the link in the site map contribution.

// display the product model and name with link (including language):
echo "<td class=main>" . $products['products_model'] . "</td><td class=main>\n<a href=\"" . tep_href_link(FILENAME_PRODUCT_INFO, 'name=' .str_replace("/", "/", rawurlencode($prod_name['products_name'])). '&products_id=' . $prod_name['products_id'] . '&language=' . $this_language_code, 'NONSSL', true) . "\">" . $prod_name['products_name'] . "</a></tr>";

Share this post


Link to post
Share on other sites
The .htaccess code should be like this:

RewriteEngine On 
RewriteBase /catalog/
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}

Notice you need to have the RewriteEngine On before the others...

 

Bobby

 

 

Ouch! How Embarrasing!!

 

I missed the 1st line of code in the copy and paste exercise.

 

Thank you very much for your help. This is now up and running fine! great Contribution.

Share this post


Link to post
Share on other sites

Hi Chemo,

 

Thanks for the excellent contribution.

 

Got a couple of gremlins I hope someone can help iron out.

 

I tried the earlier cnames version and it worked a treat.

 

Tried the new version and only problem is, it appears to work exactly the same.

 

To clarify...

 

Everything appears to be installed fine. Got the install page to run etc.

 

Everything is great except, I was keen to try the "Rewrite" option.

 

Problem is, when I switch it on, it does not appear to make any difference. It operates (generates links) exactly the same as the cname option.

 

I've wiped the contents of the cache directory. And retested, and the result is the same. Works perfectly, but only as cname regardless of setting chsen from Admin.

 

I've updated my .htaccess file (in the catalog directory), including changing '/folder/' to '/cat/'

 

 

Any suggestions ?

 

One point worth mentioning, I can't specify an apsolute path to the cache directory in the config.

 

It fails with can't find...

 

I enter '/public_html/cat/spcache/' which is the full path, but it fails miserably.

 

However, if I enter '../cat/spcache' it works. (but without rewrite functionality)

 

It is runninbg on a linux box.

 

details below :

 

Operating system Linux

Server Name  Apache version 1.3.33 (Unix)

PERL version 5.8.3

PHP version 4.3.10

MySQL version 4.0.22-standard

 

Thanks,

 

Zuber

Share this post


Link to post
Share on other sites

Zuber,

 

Your path is not configured correctly. A quick way of getting your full path is to create a phpinfo page.

 

I can tell that your path is not the FULL path.

 

You can contact me on AIM or MSN messenger for support on this...

 

Bobby

Share this post


Link to post
Share on other sites

Bobby,

 

I found a bit of an issue.

 

Seems that the products don't get added to the cache file if you use EasyPopulate to upload your new products.

 

For now, I just deleted the cache file and reloaded. Everything is fine. Maybe the delete file should be added to the EP program?

 

THat's it for tonight. THis old guy needs some sleep.

 

Paul

Share this post


Link to post
Share on other sites

It would probably be better to just add a handy reset cache button to settings. This way if something like that happens you can delete the cache file(s) without having to FTP in.

 

Bobby

Share this post


Link to post
Share on other sites

Install was very nicely done! I've always liked your install.html, Bobby. Nice and easy. I particularly liked the install script rather than having to open phpMyAdmin. It makes it more foolproof. The "Upgrade" section needs to reiterate to add the .htaccess bit, not just to run #3, #4, upgrade script.

 

Server info

Apache on FreeBSD 4.8-STABLE

Ultimate SEO URLs 1.1 installed

 

Exact problem1

USING CNAME OPTION: I've noticed that when listing the contents in a category (i.e. what would normally be a index.php?cPath=xxx URL), that AFTER I click the "buy now" button in a product listing (I've configured mine to NOT immediately take you to the shopping cart in that circumstance), all of the "buy now" buttons get rewritten to be the identical URL. This has the unfortunate effect of adding exactly the same item to the cart each and every subsequent "buy now" click, no matter which product they are wishing to add to the cart.

 

I see this problem with the 1.4 cName/pName code, as well as the current Ultimate SEO URLs code.

 

Exact problem2

USING REWRITE OPTION: The "buy now" button, in the same location as explained above, does not seem to work at all. The URL listed is http://mydomain.com/making-memories-blue-c...buy_now&sort=2a . When I click on it, the URL displayed in my browser is http://mydomain.com/product_info.php?sort=2a

 

Debugging

- Turned off osC stock caching for manufacturers box, categories box, also purchased boxes

- Turned off Page Cache

- verified that SEF URLs are off (just to be sure, though I haven't enabled them for many moons)

- tried the .htaccess both ways, since I am doing this in a testing area (but osC is docrooted to that area)

- LiveHTTPHeaders extension for Firefox shows me that when FF does a GET for http://mydomain.com/making-memories-blue-c...buy_now&sort=2a gets a 302 redirect to http://mydomain.com/product_info.php?sort=2a . I also saw cookies for my admin area and my phpbb area. Closed, re-opened browser, killed cache and cookies. No effect, other than getting an osCsid cookie set (since I'd just cleared all of those) when attempting to add the item to the cart.

- noticed that you are not having these problems on your test server, so began to wonder if this has something to do with the fact that I'm not redirecting to shopping_cart.php when an item is added to the cart.

-- turned that back on (Admin > Configuration > Display Cart After Adding Product > True (was set to False) = ITEMS ADD TO THE CART NOW! (but I don't want it to work this way . . .) This appears to resolve Problem1 and Problem2.

 

So, I now have a workaround. I know that my wife (it's her store) will not want it configured this way, though . . . I'm not sure how to fix it at 2am. Maybe tomorrow night, if Bobby hasn't beaten me to it (You're notoriously fast). <grin>

 

 

Bobby, I have a new staging area so it'd be super easy to create you an account if you'd like.

 

-jared

Share this post


Link to post
Share on other sites
It's amazing what it'll do when configured correctly :)

 

Try turnng on the rewrite option and then clear all your cache files...it gets even better! :)

 

Bobby

 

Hi Bobby

 

Ok, i know its early so i'm using that excuse lol. When you say clear the cache files, i assume you mean to delete the file seo_english.cacheseo_english.cache which is in the new cache dir i made during the install?

 

I have tried to change to rewrite, but when i do i get 404 errors on every cat and prod. I deleted the seo_english.cacheseo_english.cache file straight after changing the setting.

 

Any ideas what may be wrong?

 

Paul


Regards

Paul

Share this post


Link to post
Share on other sites

Got it, thanks.

 

Working fine now.

 

A couple of things spring to mind for future enhancements...

 

1.

 

For the static type htm pages, I still like the idea of including the immediate category as well as product title as part of the URL.

 

e.g.

 

We have generic products that will work with many devices. However, we list them under the category for each device.

 

So, we have categories Dell, HP, Toshiba all containing the same product.

 

This potentially makes a big difference in user searches.

 

2.

 

How about option for somehow not loosing the old cached links in some way.

 

a. Perhaps have a time stamp and offer delete old endtries over x days option.

 

Or

 

b. simply offer option whether or not to delete entry on update. Though that could leave alot of left over code.

 

With a. You could potentially change URL type and still leave the old URLs in there.

 

Just some ideas...

 

Thanks again for the excellent contribution.

 

Zuber

Share this post


Link to post
Share on other sites

Hi,

 

Just wondering if this contrib is likely to work with the sts template system. I have already read that your Page Cache is not recommended to be installed with sts.

 

Cheers,

Rich


Only Dead Fish Go With The Flow......

Share this post


Link to post
Share on other sites
Exact problem1

USING CNAME OPTION:  I've noticed that when listing the contents in a category (i.e. what would normally be a index.php?cPath=xxx URL), that AFTER I click the "buy now" button in a product listing (I've configured mine to NOT immediately take you to the shopping cart in that circumstance), all of the "buy now" buttons get rewritten to be the identical URL.  This has the unfortunate effect of adding exactly the same item to the cart each and every subsequent "buy now" click, no matter which product they are wishing to add to the cart.

 

Exact problem2

USING REWRITE OPTION:  The "buy now" button, in the same location as explained above, does not seem to work at all.  The URL listed is http://mydomain.com/making-memories-blue-c...buy_now&sort=2a .  When I click on it, the URL displayed in my browser is http://mydomain.com/product_info.php?sort=2a

OK...here is the quick fix. 2 files need to be changed: application_top.php and product_listing.php.

 

In application_top.php find this code:

    if (DISPLAY_CART == 'true') {
     $goto =  FILENAME_SHOPPING_CART;
     $parameters = array('action', 'cPath', 'products_id', 'pid');
   } else {
     $goto = basename($PHP_SELF);
     if ($HTTP_GET_VARS['action'] == 'buy_now') {
       $parameters = array('action', 'pid', 'products_id');
     } else {
       $parameters = array('action', 'pid');
     }
   }

and replace it with this:

    if (DISPLAY_CART == 'true') {
     $goto =  FILENAME_SHOPPING_CART;
     $parameters = array('action', 'cPath', 'products_id', 'pid', 'cName', 'pName');
   } else {
     $goto = basename($PHP_SELF);
     if ($HTTP_GET_VARS['action'] == 'buy_now') {
       $parameters = array('action', 'pid', 'products_id', 'pName');
     } else {
       $parameters = array('action', 'pid');
     }
   }

Notice that all we did was add cName and pName to the list of excluded parameters.

 

Next, find this code:

      case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
                               if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
                               } else {
                                 $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;

and replace it with this:

      case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
                               if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
                               } else {
                                 $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
                               }
                             }
        if ( (defined('SEO_URLS') && SEO_URLS == 'true') && (defined('SEO_URLS_TYPE') && SEO_URLS_TYPE == 'Rewrite') ){
         $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
       $cPath_array = tep_parse_category_path($cPath);
       $cPath = implode('_', $cPath_array);	
       tep_redirect(tep_href_link($goto, 'cPath=' . $cPath . '&' . tep_get_all_get_params($parameters)));
        } else {
                            	 tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
        }
                             break;

The issue is that since we only pass the products_id with the Rewrite it must get the cPath to redirect to.

 

Next, to correct the issue of persistent products_id (pName) in the buy now column edit includes/modules/product_listing.php. Find this code:

          case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;

and replace it with this:

          case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'pName')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;

Notice all we did was add pName to the excluded parameters.

 

With these changes the buy now should function with both cName and Rewrite.

Hi Bobby

 

Ok, i know its early so i'm using that excuse lol. When you say clear the cache files, i assume you mean to delete the file seo_english.cacheseo_english.cache which is in the new cache dir i made during the install?

 

I have tried to change to rewrite, but when i do i get 404 errors on every cat and prod. I deleted the seo_english.cacheseo_english.cache file straight after changing the setting.

 

Any ideas what may be wrong?

 

Paul

If you use the stock osC cache system, which you should be for performance reasons, then go to Admin Control Panel -> Tools -> Cache Control -> RESET ALL THE CACHE FILES

 

If you use my Page Cache contribution then also go to Admin Control Panel -> Page Cache Settings -> Delete Cache Files -> TRUE

 

The issue is if the areas (boxes or pages) are cached then the old links will be stored and the results not immediately displayed.

 

Hi,

 

Just wondering if this contrib is likely to work with the sts template system.  I have already read that your Page Cache is not recommended to be installed with sts.

 

Cheers,

Rich

It *should* work with STS since the contribution affects the osC core and not presentation layer. It has been tested and verified 100% compatible with BTS and there is no reason that it should NOT work with STS.

 

Bobby

Share this post


Link to post
Share on other sites
...

I have tried to change to rewrite, but when i do i get 404 errors on every cat and prod. I deleted the seo_english.cacheseo_english.cache file straight after changing the setting.

 

Any ideas what may be wrong?

 

Paul

ooops...forgot to answer your second part of the post :)

 

My first guess would be that you did not perform the .htaccess file edit and hence do not have anything rewriting the URLs. If you forgot to do that step it will give 404 errors as you describe.

 

Go back and verify that you did indeed make the changes...the code should look like this:

RewriteEngine On 
RewriteBase /
# or, RewriteBase /catalog/ depending on if it is root or folder install
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}

 

Bobby

Share this post


Link to post
Share on other sites

Hi, great contribution but i have a problem, I have installed all ok but:

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home//public_html//includes/functions/html_output.php:427) in /home//public_html//includes/functions/sessions.php on line 67

 

Can you help me please, thanks. :'(

Share this post


Link to post
Share on other sites
Hi, great contribution but i have a problem, I have installed all ok but:

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home//public_html//includes/functions/html_output.php:427) in /home//public_html//includes/functions/sessions.php on line 67

 

Can you help me please, thanks.  :'(

 

 

Make sure you don't have any spaces after the "?>" last line in the file.

 

Paul

Share this post


Link to post
Share on other sites
It would probably be better to just add a handy reset cache button to settings.  This way if something like that happens you can delete the cache file(s) without having to FTP in.

 

Bobby

 

Yea, I agree. That would be a nice feature. But, I was thinking that a 'reset' for that file coded in to the EP file itself would be nice too. But, that involves modifying a contrib and that just getts to wild to change later. Would there be any other way to make this automagic?

 

Paul

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×