swekidz Posted January 31, 2010 Share Posted January 31, 2010 Hi Peter Thanks for helping me this is what i have : // remove duplicate content with canonical tag by Spooks 12/2009 function CanonicalLink( $xhtml = false , $ssl = 'SSL' ) { global $request_type; $close_tag = ( false === $xhtml ? ' >' : ' />' ); $spage = ''; $domain = ( $request_type == 'SSL' && $ssl == 'SSL' ? HTTPS_SERVER : HTTP_SERVER ); // gets the base URI // Find the file basename safely = PHP_SELF is unreliable - SCRIPT_NAME can show path to phpcgi if ( array_key_exists( 'SCRIPT_NAME', $_SERVER ) && ( substr( basename( $_SERVER['SCRIPT_NAME'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['SCRIPT_NAME'] ); } elseif ( array_key_exists( 'PHP_SELF', $_SERVER ) && ( substr( basename( $_SERVER['PHP_SELF'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['PHP_SELF'] ); } else { // No base file so we have to return nothing return false; } // Don't produce canonicals for SSL pages that bots shouldn't see $ignore_array = array( 'account', 'address', 'checkout', 'login', 'password', 'logoff' ); // partial match to ssl filenames foreach ( $ignore_array as $value ) { $spage .= '(' . $value . ')|'; } $spage = rtrim($spage,'|'); if (preg_match("/$spage/", $basefile)) return false; // REQUEST_URI usually doesn't exist on Windows servers ( sometimes ORIG_PATH_INFO doesn't either ) if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) { $request_uri = $_SERVER['REQUEST_URI']; } elseif( array_key_exists( 'ORIG_PATH_INFO', $_SERVER ) ) { $request_uri = $_SERVER['ORIG_PATH_INFO']; } else { // we need to fail here as we have no REQUEST_URI and return no canonical link html return false; } $remove_array = array( 'currency','language','fl','main_page','page','cpath','products_id','sort','ref','affiliate_banner_id','max'); // Add to this array any additional params you need to remove in the same format as the existing foreach ( $remove_array as $value ) { $search[] = '/&*' . $value . '=\w*/'; } $search[] = ('/&*osCsid.*/'); $search[] = ('/\?\z/'); $request_uri = preg_replace('/\?&/', '?', preg_replace($search, '', $request_uri )); echo '<link rel="canonical" href="' . $domain . $request_uri . '"' . $close_tag . PHP_EOL; } /// /Regards SweKidz - Marcus Hi Marcus, Oh, it seems your problem is related to the search-engine-frindly-url. The SEFU will handle the url in a other way as it handled "normaly". In normal mode the url will be allprods.php?sort=2a&page=2 the SEFU will generate the same url as /allprods.php/sort/2a/page/2. I do not realy know whether the "Replying to Remove & Prevent duplicate ... with canonical tag" can handle the url's generated by the SEFU-module. If you like to remove the products_id for special.php you have to set it to: $remove_array_page = array('product_info.php' => array('manufacturers_id') // e.g. manufacturers_id has to be removed in product_info.php ,'index.php' => array() // e.g. nothing to remove in addition to the general-remove-array in index.php ,'allprods.php' => array('fl') ,'specials.php' => array('products_id') ); Please ignore the product_info, index.php, allprods.php line within the array. If you like you can send me your lines defining the $remove_array_page regards peter Quote Link to comment Share on other sites More sharing options...
swekidz Posted January 31, 2010 Share Posted January 31, 2010 Hi Spooks Thanks to you to Spooks About robots.txt what should a write there to remove the buy_now ? /Best Regards Marcus This does not support search-engine-frindly-url (still in development), to add some support, change: $search[] = '/&*' . $value . '=\w*/'; to $search[] = '/&*' . $value . '[=\/]+\w*/'; but issues could arise, ie if a param is set but has no value. products_id should not be added for removal as it is required. buy_now implies you have issues with cart pages, but they should be excluded from the bots with robots.txt Quote Link to comment Share on other sites More sharing options...
hobbynet Posted January 31, 2010 Share Posted January 31, 2010 Hi Spooks Thanks to you to Spooks About robots.txt what should a write there to remove the buy_now ? /Best Regards Marcus Hi Marcus, You can place the buy_now.php in robots.txt as follows: User-agent: * Disallow: /buy_now.php Disallow: /catalog/buy_now.php If you have an existing list of files you only have to add the two "dissallow" lines. The line "User-agent: *" will prevent all agents to access the listed files. But - not all spiders (bad agents) will properly handle the robots.txt You can also prevent the google-image-spider to access your images by adding: User-agent: Googlebot-Image Disallow: / Disallow: /catalog/ Disallow: /catalog Hope this help kind regards peter Quote Link to comment Share on other sites More sharing options...
spooks Posted January 31, 2010 Author Share Posted January 31, 2010 About robots.txt what should a write there to remove the buy_now ? buy now is a param, so isn't added to robots.txt, but checkout process etc pages (that process that) must be, ie: User-agent: * Disallow: /catalog/shopping_cart.php Disallow: /catalog/includes Disallow: /catalog/account.php Disallow: /catalog/account_edit.php Disallow: /catalog/account_history.php Disallow: /catalog/account_history_info.php Disallow: /catalog/account_password.php Disallow: /catalog/add_checkout_success.php Disallow: /catalog/address_book.php Disallow: /catalog/address_book_process.php Disallow: /catalog/checkout_confirmation.php Disallow: /catalog/checkout_payment.php Disallow: /catalog/checkout_payment_address.php Disallow: /catalog/checkout_process.php Disallow: /catalog/checkout_shipping.php Disallow: /catalog/checkout_shipping_address.php Disallow: /catalog/checkout_success.php Disallow: /catalog/cookie_usage.php Disallow: /catalog/create_account.php Disallow: /catalog/create_account_success.php Disallow: /catalog/login.php Disallow: /catalog/password_forgotten.php Disallow: /catalog/popup_image.php Disallow: /catalog/product_reviews_write.php Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
spooks Posted January 31, 2010 Author Share Posted January 31, 2010 Hi Sam, I have implement some line of code within you function. Please take a look: //hobbynet: deactivate the original array setting code //$remove_array = array( 'currency','language','main_page','page','sort','ref','affiliate_banner_id','max'); // Add to this array any additional params you need to remove in the same format as the existing //hobbynet: set parms to be removed in general $remove_array_general = array( 'currency','language','main_page','page','sort','ref','affiliate_banner_id','max'); //hobbynet: set parms to be remove for each defined page //hobbynet: can be enhanced with the page-name e.g. specials.php as the key and set the parms to be removed in the second array //hobbynet: keep in mind; each page-specific array entry has to be splitted with "," (comma) $remove_array_page = array('product_info.php' => array('manufacturers_id') // e.g. manufacturers_id has to be removed in product_info.php ,'index.php' => array() // e.g. nothing to remove in addition to the general-remove-array ); //hobbynet: merge arrays together general-removal-array and page-specific-removal_array //hobbynet: $basefile is set to the current requested page //hobbynet: get the page-specific-removal-array keyed by the value in $basefile with "$remove_array_page[$basefile]" $remove_array_merged = array_merge($remove_array_general, $remove_array_page[$basefile]); //hobbynet: use the new $remove_array_merged in stead of the orig. $remove_array foreach ( $remove_array_merged as $value ) { It will work and it will remove e.g. the manufacturers_id in product_info.php but not in index.php or other pages Looks good, I can see that'll work. Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
swekidz Posted January 31, 2010 Share Posted January 31, 2010 Hi again :) What about this code were should i put that : $remove_array_page = array('product_info.php' => array('manufacturers_id') // e.g. manufacturers_id has to be removed in product_info.php ,'index.php' => array() // e.g. nothing to remove in addition to the general-remove-array in index.php ,'allprods.php' => array('fl') ,'specials.php' => array('products_id') ); /Regards SweKidz - Marcus Hi Marcus, You can place the buy_now.php in robots.txt as follows: User-agent: * Disallow: /buy_now.php Disallow: /catalog/buy_now.php If you have an existing list of files you only have to add the two "dissallow" lines. The line "User-agent: *" will prevent all agents to access the listed files. But - not all spiders (bad agents) will properly handle the robots.txt You can also prevent the google-image-spider to access your images by adding: User-agent: Googlebot-Image Disallow: / Disallow: /catalog/ Disallow: /catalog Hope this help kind regards peter Quote Link to comment Share on other sites More sharing options...
hobbynet Posted January 31, 2010 Share Posted January 31, 2010 Hi again :) What about this code were should i put that : $remove_array_page = array('product_info.php' => array('manufacturers_id') // e.g. manufacturers_id has to be removed in product_info.php ,'index.php' => array() // e.g. nothing to remove in addition to the general-remove-array in index.php ,'allprods.php' => array('fl') ,'specials.php' => array('products_id') ); /Regards SweKidz - Marcus Hi Marcus, I've enhanced the function CanonicalLink to specifiy a removal array for general and removal array for a specific page. Why to specify removal tag for a specific page? Take a look at the product_info.php if it's selected from the online store. The canonical link only show as <link rel="canonical" href="........../product_info.php?products_id=494" /> but if you select on the start page a manufacturer and after select a product the new canonical link will includes the manufacturers_id as <link rel="canonical" href="...../product_info.php?manufacturers_id=23&products_id=494" /> but these two canonicals will go into the duplicates in google so the manufactureres_id has to be removed in product_info.php. The thing is, the manufactureres_id do not have to remove for the index.php So if you define the manufactueres_id in the original $remove_array array the tag will be removed in any page. The complete function look now like: // remove duplicate content with canonical tag by Spooks 12/2009 function CanonicalLink( $xhtml = false , $ssl = 'SSL' ) { global $request_type; $close_tag = ( false === $xhtml ? ' >' : ' />' ); $spage = ''; $domain = ( $request_type == 'SSL' && $ssl == 'SSL' ? HTTPS_SERVER : HTTP_SERVER ); // gets the base URI // Find the file basename safely = PHP_SELF is unreliable - SCRIPT_NAME can show path to phpcgi if ( array_key_exists( 'SCRIPT_NAME', $_SERVER ) && ( substr( basename( $_SERVER['SCRIPT_NAME'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['SCRIPT_NAME'] ); } elseif ( array_key_exists( 'PHP_SELF', $_SERVER ) && ( substr( basename( $_SERVER['PHP_SELF'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['PHP_SELF'] ); } else { // No base file so we have to return nothing return false; } // Don't produce canonicals for SSL pages that bots shouldn't see $ignore_array = array( 'account', 'address', 'checkout', 'login', 'password', 'logoff' ); // partial match to ssl filenames foreach ( $ignore_array as $value ) { $spage .= '(' . $value . ')|'; } $spage = rtrim($spage,'|'); if (preg_match("/$spage/", $basefile)) return false; // REQUEST_URI usually doesn't exist on Windows servers ( sometimes ORIG_PATH_INFO doesn't either ) if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) { $request_uri = $_SERVER['REQUEST_URI']; } elseif( array_key_exists( 'ORIG_PATH_INFO', $_SERVER ) ) { $request_uri = $_SERVER['ORIG_PATH_INFO']; } else { // we need to fail here as we have no REQUEST_URI and return no canonical link html return false; } //hobbynet: deactivate the original array setting code //$remove_array = array( 'currency','language','main_page','page','sort','ref','affiliate_banner_id','max'); //hobbynet: set parms to be removed in general // Add to this array any additional params you need to remove in the same format as the existing $remove_array_general = array( 'currency','language','main_page','page','sort','ref','affiliate_banner_id','max','view_all'); //hobbynet: set parms to be remove for each defined page //hobbynet: can be enhanced with the page-name e.g. specials.php as the key and set the parms to be removed in the second array //hobbynet: keep in mind; each page-specific array entry has to be splitted with "," (comma) $remove_array_page = array('product_info.php' => array('manufacturers_id','cPath') // e.g. manufacturers_id has to be removed in product_info.php ,'index.php' => array() // e.g. nothing to remove in addition to the general-remove-array in index.php ,'allprods.php' => array('fl') ,'specials.php' => array('action') ); //hobbynet: merge arrays together general-removal-array and page-specific-removal_array //hobbynet: $basefile is set to the current requested page //hobbynet: get the page-specific-removal-array keyed by the value in $basefile with "$remove_array_page[$basefile]" $remove_array_merged = array_merge($remove_array_general, $remove_array_page[$basefile]); //hobbynet: use the new $remove_array_merged in stead of the orig. $remove_array foreach ( $remove_array_merged as $value ) { $search[] = '/&*' . $value . '=\w*/'; } $search[] = ('/&*osCsid.*/'); $search[] = ('/\?\z/'); $request_uri = preg_replace('/\?&/', '?', preg_replace($search, '', $request_uri )); echo '<link rel="canonical" href="' . $domain . $request_uri . '"' . $close_tag . PHP_EOL; } /// located in the file mentioned by Sam hope this help. regards peter Quote Link to comment Share on other sites More sharing options...
yubnub Posted February 1, 2010 Share Posted February 1, 2010 (edited) hi Spooks (sam), Just a quick thank you for this wonderful contribution. I have had it instlaled for less than 48 hours and already my duplicate warnings in google have dropped from 3000 warnings (!!) to 1600, It is obviously working a charm, many thanks again - i would recommend this to all, regards, anthony Edited February 1, 2010 by yubnub Quote Link to comment Share on other sites More sharing options...
swekidz Posted February 2, 2010 Share Posted February 2, 2010 Hi When i installed this it was like this : /?manufacturers_id=12&cpath=29&products_id=109" > before it was : /?manufacturers_id=12 Do you now whats wrong then ? /Best Regards Marcus Hi Marcus, I've enhanced the function CanonicalLink to specifiy a removal array for general and removal array for a specific page. Why to specify removal tag for a specific page? Take a look at the product_info.php if it's selected from the online store. The canonical link only show as <link rel="canonical" href="........../product_info.php?products_id=494" /> but if you select on the start page a manufacturer and after select a product the new canonical link will includes the manufacturers_id as <link rel="canonical" href="...../product_info.php?manufacturers_id=23&products_id=494" /> but these two canonicals will go into the duplicates in google so the manufactureres_id has to be removed in product_info.php. The thing is, the manufactureres_id do not have to remove for the index.php So if you define the manufactueres_id in the original $remove_array array the tag will be removed in any page. The complete function look now like: // remove duplicate content with canonical tag by Spooks 12/2009 function CanonicalLink( $xhtml = false , $ssl = 'SSL' ) { global $request_type; $close_tag = ( false === $xhtml ? ' >' : ' />' ); $spage = ''; $domain = ( $request_type == 'SSL' && $ssl == 'SSL' ? HTTPS_SERVER : HTTP_SERVER ); // gets the base URI // Find the file basename safely = PHP_SELF is unreliable - SCRIPT_NAME can show path to phpcgi if ( array_key_exists( 'SCRIPT_NAME', $_SERVER ) && ( substr( basename( $_SERVER['SCRIPT_NAME'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['SCRIPT_NAME'] ); } elseif ( array_key_exists( 'PHP_SELF', $_SERVER ) && ( substr( basename( $_SERVER['PHP_SELF'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['PHP_SELF'] ); } else { // No base file so we have to return nothing return false; } // Don't produce canonicals for SSL pages that bots shouldn't see $ignore_array = array( 'account', 'address', 'checkout', 'login', 'password', 'logoff' ); // partial match to ssl filenames foreach ( $ignore_array as $value ) { $spage .= '(' . $value . ')|'; } $spage = rtrim($spage,'|'); if (preg_match("/$spage/", $basefile)) return false; // REQUEST_URI usually doesn't exist on Windows servers ( sometimes ORIG_PATH_INFO doesn't either ) if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) { $request_uri = $_SERVER['REQUEST_URI']; } elseif( array_key_exists( 'ORIG_PATH_INFO', $_SERVER ) ) { $request_uri = $_SERVER['ORIG_PATH_INFO']; } else { // we need to fail here as we have no REQUEST_URI and return no canonical link html return false; } //hobbynet: deactivate the original array setting code //$remove_array = array( 'currency','language','main_page','page','sort','ref','affiliate_banner_id','max'); //hobbynet: set parms to be removed in general // Add to this array any additional params you need to remove in the same format as the existing $remove_array_general = array( 'currency','language','main_page','page','sort','ref','affiliate_banner_id','max','view_all'); //hobbynet: set parms to be remove for each defined page //hobbynet: can be enhanced with the page-name e.g. specials.php as the key and set the parms to be removed in the second array //hobbynet: keep in mind; each page-specific array entry has to be splitted with "," (comma) $remove_array_page = array('product_info.php' => array('manufacturers_id','cPath') // e.g. manufacturers_id has to be removed in product_info.php ,'index.php' => array() // e.g. nothing to remove in addition to the general-remove-array in index.php ,'allprods.php' => array('fl') ,'specials.php' => array('action') ); //hobbynet: merge arrays together general-removal-array and page-specific-removal_array //hobbynet: $basefile is set to the current requested page //hobbynet: get the page-specific-removal-array keyed by the value in $basefile with "$remove_array_page[$basefile]" $remove_array_merged = array_merge($remove_array_general, $remove_array_page[$basefile]); //hobbynet: use the new $remove_array_merged in stead of the orig. $remove_array foreach ( $remove_array_merged as $value ) { $search[] = '/&*' . $value . '=\w*/'; } $search[] = ('/&*osCsid.*/'); $search[] = ('/\?\z/'); $request_uri = preg_replace('/\?&/', '?', preg_replace($search, '', $request_uri )); echo '<link rel="canonical" href="' . $domain . $request_uri . '"' . $close_tag . PHP_EOL; } /// located in the file mentioned by Sam hope this help. regards peter Quote Link to comment Share on other sites More sharing options...
hobbynet Posted February 2, 2010 Share Posted February 2, 2010 Hi When i installed this it was like this : /?manufacturers_id=12&cpath=29&products_id=109" > before it was : /?manufacturers_id=12 Do you now whats wrong then ? /Best Regards Marcus Hi Marcus, Do you now installed my enhanced function? Please post the lines as follows: $remove_array_general = array(... $remove_array_page = array(... It seems the cpath and products_id arn't defined for removal. regards peter Quote Link to comment Share on other sites More sharing options...
swekidz Posted February 3, 2010 Share Posted February 3, 2010 (edited) Hi The problem thats left is this : http://www. homepage.se/allprods.php/sort/2a/page/5" > /Regards Marcus Edited February 3, 2010 by swekidz Quote Link to comment Share on other sites More sharing options...
spooks Posted February 3, 2010 Author Share Posted February 3, 2010 (edited) Uploaded new version 1.3 Modified code to allow removal of params in specific pages. Code & idea by hobbynet thanks. Modified code to allow option of removal of index.php from the uri. Added partial compatibilty with 'search-engine-frindly-url (still in development)', note issues could arise, ie if a param is set but has no value. Enjoy Edited February 3, 2010 by spooks Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
swekidz Posted February 4, 2010 Share Posted February 4, 2010 Hi When i installs the new 1.3 when i look at the code it says : Warning: array_merge(): Argument #2 is not an array in /hsphere/local/home/swehealth/swehealth.se/includes/functions/html_output.php on line 353 Warning: Invalid argument supplied for foreach() in /hsphere/local/home/swehealth/swehealth.se/includes/functions/html_output.php on line 355 this code : // remove duplicate content with canonical tag by Spooks 12/2009 function CanonicalLink( $xhtml = false , $ssl = 'SSL' ) { global $request_type; $rem_index = false; // Set to true to additionally remove index.php from the uri $close_tag = ( false === $xhtml ? ' >' : ' />' ); $spage = ''; $domain = ( $request_type == 'SSL' && $ssl == 'SSL' ? HTTPS_SERVER : HTTP_SERVER ); // gets the base URI // Find the file basename safely = PHP_SELF is unreliable - SCRIPT_NAME can show path to phpcgi if ( array_key_exists( 'SCRIPT_NAME', $_SERVER ) && ( substr( basename( $_SERVER['SCRIPT_NAME'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['SCRIPT_NAME'] ); } elseif ( array_key_exists( 'PHP_SELF', $_SERVER ) && ( substr( basename( $_SERVER['PHP_SELF'] ), -4, 4 ) == '.php' ) ) { $basefile = basename( $_SERVER['PHP_SELF'] ); } else { // No base file so we have to return nothing return false; } // Don't produce canonicals for SSL pages that bots shouldn't see $ignore_array = array( 'account', 'address', 'checkout', 'login', 'password', 'logoff' ); // partial match to ssl filenames foreach ( $ignore_array as $value ) { $spage .= '(' . $value . ')|'; } $spage = rtrim($spage,'|'); if (preg_match("/$spage/", $basefile)) return false; // REQUEST_URI usually doesn't exist on Windows servers ( sometimes ORIG_PATH_INFO doesn't either ) if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) { $request_uri = $_SERVER['REQUEST_URI']; } elseif( array_key_exists( 'ORIG_PATH_INFO', $_SERVER ) ) { $request_uri = $_SERVER['ORIG_PATH_INFO']; } else { // we need to fail here as we have no REQUEST_URI and return no canonical link html return false; } $remove_array = array( 'currency','language','main_page','page','sort','ref','affiliate_banner_id','max'); // Add to this array any additional params you need to remove in the same format as the existing $page_remove_array = array(FILENAME_PRODUCT_INFO => array('manufacturers_id', 'cPath'), FILENAME_DEFAULT => array() ); // remove page specific params, should be in same format as previous, given is manufacturers_id & cPath // have to be removed in product_info.php only $remove_array = array_merge($remove_array, $page_remove_array[$basefile]); foreach ( $remove_array as $value ) { $search[] = '/&*' . $value . '[=\/]+\w*\/?/i'; } $search[] = ('/&*osCsid.*/'); $search[] = ('/\?\z/'); if ($rem_index) $search[] = ('/index.php\/*/'); $request_uri = preg_replace('/\?&/', '?', preg_replace($search, '', $request_uri )); echo '<link rel="canonical" href="' . $domain . $request_uri . '"' . $close_tag . PHP_EOL; } /// /Regards Marcus Uploaded new version 1.3 Modified code to allow removal of params in specific pages. Code & idea by hobbynet thanks. Modified code to allow option of removal of index.php from the uri. Added partial compatibilty with 'search-engine-frindly-url (still in development)', note issues could arise, ie if a param is set but has no value. Enjoy Quote Link to comment Share on other sites More sharing options...
spooks Posted February 4, 2010 Author Share Posted February 4, 2010 Warning: array_merge(): Argument #2 is not an array When i installs the new 1.3 when i look at the code it says : Warning: array_merge(): Argument #2 is not an array in /hsphere/local/home/swehealth/swehealth.se/includes/functions/html_output.php on line 353 Warning: Invalid argument supplied for foreach() in /hsphere/local/home/swehealth/swehealth.se/includes/functions/html_output.php on line 355 OOPS, yes sorry, should have thought of that senario! Replace: $remove_array = array_merge($remove_array, $page_remove_array[$basefile]); With: if (is_array($page_remove_array[$basefile])) $remove_array = array_merge($remove_array, $page_remove_array[$basefile]); Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
swekidz Posted February 4, 2010 Share Posted February 4, 2010 Hi Spooks! Thanks for the help! Now it works :) /Best Regards Marcus Warning: array_merge(): Argument #2 is not an array OOPS, yes sorry, should have thought of that senario! Replace: $remove_array = array_merge($remove_array, $page_remove_array[$basefile]); With: if (is_array($page_remove_array[$basefile])) $remove_array = array_merge($remove_array, $page_remove_array[$basefile]); Quote Link to comment Share on other sites More sharing options...
tigergirl Posted February 5, 2010 Share Posted February 5, 2010 (edited) Hi Sam, I've been looking at this mod with interest. I can see I have some duplicate content with cPath. I have Header Tags Controller but no URL re-writer. I can see that a product listed with and without cPath would be duplicate content. product_info.php?products_id=110 product_info.php?cPath=31_53&products_id=110 How will removing removing cPath affect how google deals with a category/ sub category as these may be indexed separately on their own (without products I mean), how will the canonical look without URL re-writer for /index.php?cPath=31 for instance? Or does the code deal with that already? I've also got the issue of inactive or deleted products/ categories/ manufacturers getting a 200 "Product Not found" etc instead of a 301 redirect/ 404 page not found and there doesn't seem to be a good way to deal with this that I can find. Google keeps visiting these pages. Edited February 5, 2010 by tigergirl Quote I'm feeling lucky today......maybe someone will answer my post! I do try and answer a simple post when I can just to give something back. ------------------------------------------------ PM me? - I'm not for hire Link to comment Share on other sites More sharing options...
spooks Posted February 5, 2010 Author Share Posted February 5, 2010 I can see that a product listed with and without cPath would be duplicate content. product_info.php?products_id=110 product_info.php?cPath=31_53&products_id=110 Yes the latest deals with the issue of page sepecific uli , ie cpath will be removed for product info pages, but not index.php etc (see the doc) There is a bug in the latest mind, see my ealier for fix. If you add the cononical google will responde quickly, removing the duplicates but gaining rank as spead is reduced. Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
tigergirl Posted February 5, 2010 Share Posted February 5, 2010 Thanks for explaining re cPath. If you add the cononical google will responde quickly, removing the duplicates but gaining rank as spead is reduced. I presume you meant "spread" not "spead"? ;) Please can you just clarify this bit for me: If you have no 'catalog' pages on a secure server (ie only account etc. pages are there) set the 'SSL' parameter to 'NONSSL' which exact code do I need to change? Is it: CanonicalLink( $xhtml = false, 'SSL' ); in html_output & header_tags ? Thanks again Sam Quote I'm feeling lucky today......maybe someone will answer my post! I do try and answer a simple post when I can just to give something back. ------------------------------------------------ PM me? - I'm not for hire Link to comment Share on other sites More sharing options...
spooks Posted February 5, 2010 Author Share Posted February 5, 2010 I presume you meant "spread" not "spead"? sometimes my keyboard cant keep up!! SSL Yes set to NONSSL in the link CanonicalLink( $xhtml = false, 'NONSSL' ); Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
Peper Posted February 6, 2010 Share Posted February 6, 2010 Hi Sam Somehow I am getting this link - " http://localhost/shop/builder_component_info.php?products_id=52&osCsid= "on my testing server it works but not my live server Its from add on cpb builder Do we need to change anything on code provided Any help please Ps. see code ln. 24 <title><?php echo TITLE; ?></title> If we can alter this as well for better seo or should we leave as is Thank you for the excellent contributions <?php /* $Id: builder_component_info.php, v 1.1.0 2008-12-03 00:52:16 10c $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_BUILDER_COMPONENT_INFO); $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_check = tep_db_fetch_array($product_check_query); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> <script language="javascript"><!-- function popupWindow(url) { window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150') } //--></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <?php if ($product_check['total'] < 1) { ?> <tr> <td><?php new infoBox(array(array('text' => TEXT_PRODUCT_NOT_FOUND))); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } else { $product_info_query = tep_db_query("select p.products_status, p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); if ($new_price = tep_get_products_special_price($product_info['products_id'])) { $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); } if (tep_not_null($product_info['products_model'])) { $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>'; } else { $products_name = $product_info['products_name']; } ?> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading" valign="top"><?php echo $products_name; ?></td> <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td class="main"> <?php if (tep_not_null($product_info['products_image'])) { ?> <table border="0" cellspacing="0" cellpadding="2" align="right"> <tr> <td align="center" class="smallText"> <?php if ($product_info['products_status'] == '1') { ?> <script language="javascript"><!-- document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>'); //--></script> <noscript> <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?> </noscript> <?php } else { echo tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"'); } ?> </td> </tr> </table> <?php } ?> <p><?php echo stripslashes($product_info['products_description']); ?></p> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <form method="POST"> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <?php // previous / next product buttons if ($product_check['total'] >= 1 && $product_info['products_status'] == '1') { include (DIR_WS_INCLUDES . 'builder_next_previous.php'); } ?> <td class="main" align="right"><input type="button" value="Close" onClick="window.close()"></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </form> </tr> <?php } ?> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Quote Getting the Phoenix off the ground Link to comment Share on other sites More sharing options...
spooks Posted February 6, 2010 Author Share Posted February 6, 2010 I have no idea whay u r saying, but from the code u have posted u have not installed this, so no relavence!! Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
Peper Posted February 7, 2010 Share Posted February 7, 2010 I have no idea whay u r saying, but from the code u have posted u have not installed this, so no relavence!! Sorry for posting on the wrong place The link that is used at the end &osCsid= Shouldn't it remove ocsid codes? It uses a similar code as from product_reviews.php <?php if (tep_not_null($product_info['products_image'])) { ?> <script language="javascript"><!-- document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>'); //--></script> <noscript> <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?> </noscript> <?php } echo '<p><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now') . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a></p>'; ?> Quote Getting the Phoenix off the ground Link to comment Share on other sites More sharing options...
Peper Posted February 7, 2010 Share Posted February 7, 2010 (edited) Ok, OK Found the code window.open ("<?php echo FILENAME_BUILDER_COMPONENT_INFO; ?>?products_id="+recid[row]+"&osCsid=<?php echo $osCsid;?>",'', and changed to window.open ("<?php echo FILENAME_BUILDER_COMPONENT_INFO; ?>?products_id="+recid[row],'', So my link shows up as http://localhost/shop/builder_component_info.php?products_id=52 Sorry for posting on the wrong place The link that is used at the end &osCsid= Shouldn't it remove ocsid codes? It uses a similar code as from product_reviews.php <?php if (tep_not_null($product_info['products_image'])) { ?> <script language="javascript"><!-- document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>'); //--></script> <noscript> <?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?> </noscript> <?php } echo '<p><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now') . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a></p>'; ?> Edited February 7, 2010 by Peper Quote Getting the Phoenix off the ground Link to comment Share on other sites More sharing options...
spooks Posted February 7, 2010 Author Share Posted February 7, 2010 Ok, OK Found the code window.open ("<?php echo FILENAME_BUILDER_COMPONENT_INFO; ?>?products_id="+recid[row]+"&osCsid=<?php echo $osCsid;?>",'', and changed to window.open ("<?php echo FILENAME_BUILDER_COMPONENT_INFO; ?>?products_id="+recid[row],'', So my link shows up as http://localhost/shop/builder_component_info.php?products_id=52 it looks like u have some messed uip template code with hacks done as the auther don't know squote.# you must have properly generated links, with oscid if needed http://www.oscommerce.com/forums/index.php?showtopic=330479&hl this does not modify links, it generates a canonical with the correct link for the page, read the doc. as u are not calling the function, so generating the canonical, this is doing nothing. install it as detailed in the doc if u want it, but please, read the doc!! Quote Sam Remember, What you think I ment may not be what I thought I ment when I said it. Contributions: Auto Backup your Database, Easy way Multi Images with Fancy Pop-ups, Easy way Products in columns with multi buy etc etc Disable any Category or Product, Easy way Secure & Improve your account pages et al. Link to comment Share on other sites More sharing options...
tigergirl Posted February 8, 2010 Share Posted February 8, 2010 Yes set to NONSSL in the link CanonicalLink( $xhtml = false, 'NONSSL' ); Thanks for that. I think I have an issue - google has been busy but he's visiting some url's that don't/ have never existed. I see him on: product_info.php?cPath=0_26&products_id=123 and it should be: product_info.php?cPath=31_26&products_id=123 If I put in the address bar it brings up the product. I know the canonical will be product_info.php?products_id=123 but the path he is looking at doesn't follow the correct breadcrumb (and I understand the breadcrumb is important) and I'm worried that if for instance I removed this mod, I would end up with google visiting many urls that simply aren't there and we know osc has an issue with code 200's when it should be 404's/301's. How can this be so? I haven't ever noticed a bot hitting incorrect categories like that before :( . I installed jacks sitemap SEO recently but the paths seem fine on that. Quote I'm feeling lucky today......maybe someone will answer my post! I do try and answer a simple post when I can just to give something back. ------------------------------------------------ PM me? - I'm not for hire Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.