Posted - 10/28/2019 : 09:31:31
While using the SEO Friendly URLs, I had invalid urls indexing as a valid page in Google Search Console. My products.php is rewritten to /stone-products/ and my categories.php is rewritten to /stone-category/
The url /stone-products/[any string of text] would resolve to my "all products" - this resulted in thousands of pages being indexed because we had 25 pages of products. So the end result would be that the url /stone-products/[any string of text]?pg=1-25 was being indexed for any string of text.
I ended up testing for a numeric $GLOBALS['catid'] or an empty value to display the incproducts.php and if not, display an error message and throw a 404 error.
Here's the code for the products page:
[code]<?php if ((is_numeric($GLOBALS['catid'])) || (($GLOBALS['catid'])=='')){ include "[storedir]/inc/incproducts.php"; } else { header("HTTP/1.0 404 Not Found"); echo '<p><em>'.$GLOBALS['xxSryNA']; echo '<p>'; $crosssellaction='bestsellers'; include "[storedir]/inc/inccrosssell.php"; echo '</p>'; } ?>[/code]
This is category page:
[code]if ((is_numeric($GLOBALS['catid'])) || (($GLOBALS['catid'])=='')){ include "vsadmin/inc/inccategories.php"; } else { header("HTTP/1.0 404 Not Found"); echo '<p><em>'.$GLOBALS['xxSryNA']; echo ' Need something else?</em></p> echo '<p>' .'New Inventory'; $recommendedcategories=TRUE; include 'vsadmin/inc/inccategories.php'; echo '</p>'; }[/code]
Includes [code] $GLOBALS['detlinkspacechar']='-'; $GLOBALS['seodetailurls']=TRUE; $GLOBALS['seocategoryurls']=TRUE; $GLOBALS['seocaturlpattern']='/stone-category/%s'; $GLOBALS['seoprodurlpattern']='/stone-products/%s'; $GLOBALS['seourlsthrow301']=TRUE; [/code]
.htaccess [code] RewriteOptions inherit
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^stone-category/([^/.]*)?$ /categories.php?cat=$1 [QSA,nc,L,B] RewriteRule ^stone-products/([^/.]*)?$ /products.php?cat=$1 [QSA,nc,L,B] #RewriteRule ^manufacturer/([^/.]*)/?$ /products.php?man=$1 [QSA,nc,L,B] RewriteCond $1 !\.(png|gif|jpg|ico|pdf|css|js|php|xml|html|htm)$ [NC] RewriteRule ^([^/.]+)$ proddetail.php?prod=$1 [QSA,nc,L,B] </IfModule> [/code]
Hope this solution helps someone else!
Thank you, Lynne
Edited by - stonewx on 10/28/2019 21:56:28
|