Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SE Friendly URLs


blueedge

Recommended Posts

I use search engine friendly URLs on my store. The product name gets incorporated into the product's URL, along with a unique, auto-generated product id number. For example:

 

The URL for a product named "Large Green Widget" is rewriten as:

 

http://www.domain.com/large-green-widget-p-34.html

 

The Large Green Widget page is displayed even if the "large-green-widget" portion of the url is deleted or altered. The following modifified URLs all display the same page:

 

http://www.domain.com/large-grn-widget-p-34.html

http://www.domain.com/kiss-my-butt-p-34.html

http://www.domain.com/la-gr-wi-p-34.html

 

Since they each have a different URL but display the same content, I'm concerned about duplicate content.

 

How can I have URLs that, when altered and do not match the product name, resolve to the custom 404 page?

Link to comment
Share on other sites

I use search engine friendly URLs on my store. The product name gets incorporated into the product's URL, along with a unique, auto-generated product id number. For example:

 

The URL for a product named "Large Green Widget" is rewriten as:

 

http://www.domain.com/large-green-widget-p-34.html

 

The Large Green Widget page is displayed even if the "large-green-widget" portion of the url is deleted or altered. The following modifified URLs all display the same page:

 

http://www.domain.com/large-grn-widget-p-34.html

http://www.domain.com/kiss-my-butt-p-34.html

http://www.domain.com/la-gr-wi-p-34.html

 

Since they each have a different URL but display the same content, I'm concerned about duplicate content.

 

How can I have URLs that, when altered and do not match the product name, resolve to the custom 404 page?

 

Click on my "addons" (on the left somewhere) and look for the validation contribution.

Link to comment
Share on other sites

Robert, thank you!

 

That contribution was so easy to install, even I was able to do it myself. :)

 

However, I now cannot access subcategory pages, such as domain.com/keyword-keyword2-c30_55.html. When I try to access a subcategory page with the fix in place, I get Page Cannot Be Displayed error. Does the does address subcategory pages?

 

Secondly, I know that this is specific to my site . . . I have some pages that have a "tc" id in the URL, such as domain.com/top-category-tc-22.html. (The "tc" pages are considered as "top category" pages. They were added in above the regular category pages so I could have more meaningful "super" cateogries and not disturb the category URLs that I already had links pointing to.)

 

Since, naturally, the fix doesn't address "tc" pages, I tried simply inserting the following line in general.php after the line for categories:

 

( strpos($_SERVER['REQUEST_URI'], '-tc-') ? ($querytype = 'filename_default-cPath=' . $HTTP_GET_VARS['cPath']) :

 

However, this caused the entire site to fail with a php syntax error. How do I address the situtation with my "tc" pages?

 

Also, I have a custom 404 page. Is there a way to have the script use my custom 404 error page instead of the 404 error page that is created in the code in the general.php page?

 

Thanks!

Link to comment
Share on other sites

Robert, thank you!

 

That contribution was so easy to install, even I was able to do it myself. :)

 

However, I now cannot access subcategory pages, such as domain.com/keyword-keyword2-c30_55.html. When I try to access a subcategory page with the fix in place, I get Page Cannot Be Displayed error. Does the does address subcategory pages?

 

Secondly, I know that this is specific to my site . . . I have some pages that have a "tc" id in the URL, such as domain.com/top-category-tc-22.html. (The "tc" pages are considered as "top category" pages. They were added in above the regular category pages so I could have more meaningful "super" cateogries and not disturb the category URLs that I already had links pointing to.)

 

Since, naturally, the fix doesn't address "tc" pages, I tried simply inserting the following line in general.php after the line for categories:

 

( strpos($_SERVER['REQUEST_URI'], '-tc-') ? ($querytype = 'filename_default-cPath=' . $HTTP_GET_VARS['cPath']) :

 

However, this caused the entire site to fail with a php syntax error. How do I address the situtation with my "tc" pages?

 

Also, I have a custom 404 page. Is there a way to have the script use my custom 404 error page instead of the 404 error page that is created in the code in the general.php page?

 

Thanks!

 

You could try the following: -

 

( strpos($_SERVER['REQUEST_URI'], '-p-') ? ($querytype = 'filename_product_info-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-c-') ? ($querytype = 'filename_default-cPath=' . $HTTP_GET_VARS['cPath']) :
( strpos($_SERVER['REQUEST_URI'], '-m-') ? ($querytype = 'filename_default-manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']) :
( strpos($_SERVER['REQUEST_URI'], '-pi-') ? ($querytype = 'filename_popup_image-pID=' . $HTTP_GET_VARS['pID']) :
( strpos($_SERVER['REQUEST_URI'], '-t-') ? ($querytype = 'filename_articles-tPath=' . $HTTP_GET_VARS['tPath']) :
( strpos($_SERVER['REQUEST_URI'], '-tc-') ? ($querytype = 'filename_default-cPath=' . $HTTP_GET_VARS['cPath']) :
( strpos($_SERVER['REQUEST_URI'], '-a-') ? ($querytype = 'filename_article_info-articles_id=' . $HTTP_GET_VARS['articles_id']) :
( strpos($_SERVER['REQUEST_URI'], '-pr-') ? ($querytype = 'filename_product_reviews-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-pri-') ? ($querytype = 'filename_product_reviews_info-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-prw-') ? ($querytype = 'filename_product_reviews_write-products_id=' . $get_id_vars) :
( strpos($_SERVER['REQUEST_URI'], '-i-') ? ($querytype = 'filename_information-info_id=' . $HTTP_GET_VARS['info_id']) :
( strpos($_SERVER['REQUEST_URI'], '-links-') ? ($querytype = 'filename_links-lPath=' . $HTTP_GET_VARS['lPath']) :
$do_validation = false ))))))))))) );

 

Then in .htaccess add ..

 

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

 

What changes were made in seo.class.php for this to work because there is nothing in there to handle -tc- ?

Link to comment
Share on other sites

You could try the following: -

 

$this->reg_anchors = array('products_id' => '-p-',
							   'cPath' => '-c-',
							   'tcPath' => '-tc-',
							   'manufacturers_id' => '-m-',
							   'pID' => '-pi-',
							   'tPath' => '-t-',
							   'articles_id' => '-a-',
							   'products_id_review' => '-pr-',
							   'products_id_review_info' => '-pri-',
							   'info_id' => '-i-'
							   );

 

and this:

 if ( is_numeric(strpos($p2[1], '_')) ){
			 	} else {
			 	$check_query = tep_db_query("select parent_id from categories where categories_id = '" . (int)$p2[1] . "'");
			 	$check = tep_db_fetch_array($check_query);
			 	if ($check['parent_id'] == '0') {
					$p2[0] = 'tcPath';
				}

 

Unfortunately, I still get Page Cannot Be Displayed when try to access subcategory pages, such as domain.com/keyword-keyword2-c30_55.html. It is not that the redirect doesn't work for subcategory pages. It is I can't even get to the subcategory pages. I would think that since subcategories are a normal part of OSC that others would have the same problem.

Link to comment
Share on other sites

For whatever reason, the validation code causes links to subcategory pages (eg domain.com/keyword-keyword2-c-30_55.html) to fail.

 

After installing the validation code, I went around my site to make sure that everything still worked. I noticed that, unfortunately, I cannot access subcategory pages. When I now click on a subcategory link, the page fails to open and I get a Page Cannot Be Displayed error.

 

If I can't get to the subcategory URLs to work with the validation code installed, I'm afraid I'll have to remove the validation code - not something I want to do.

 

Any suggestions?

Link to comment
Share on other sites

For whatever reason, the validation code causes links to subcategory pages (eg domain.com/keyword-keyword2-c-30_55.html) to fail.

 

After installing the validation code, I went around my site to make sure that everything still worked. I noticed that, unfortunately, I cannot access subcategory pages. When I now click on a subcategory link, the page fails to open and I get a Page Cannot Be Displayed error.

 

If I can't get to the subcategory URLs to work with the validation code installed, I'm afraid I'll have to remove the validation code - not something I want to do.

 

Any suggestions?

 

Turn validation off in admin and try the same things, I doubt if it's the validation code as all it does is requests a fresh url from seo.class.php and if the incoming doesn't match it redirects.

Link to comment
Share on other sites

Thanks for the reply, Robert.

 

Unfortunately it does seem to be the validation code. As you suggested, I set the validation code to "false" in the admin and I was able to access subcategory pages (i.e. domain.com/keyword-keyword2-c-30_55.html). I, then, turned the validation to "true" in the admin and refresed the category page. When I click on the same subcategory link that appears on the category page, I received Page Cannot Be Displayed. For some reason subcategory pages are not accessible with validation turned on.

 

Any ideas?

Link to comment
Share on other sites

Thanks for the reply, Robert.

 

Unfortunately it does seem to be the validation code. As you suggested, I set the validation code to "false" in the admin and I was able to access subcategory pages (i.e. domain.com/keyword-keyword2-c-30_55.html). I, then, turned the validation to "true" in the admin and refresed the category page. When I click on the same subcategory link that appears on the category page, I received Page Cannot Be Displayed. For some reason subcategory pages are not accessible with validation turned on.

 

Any ideas?

 

Doesn't make sense .. I need to see a link .. pm if necesssary

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...