2

I am using Commerce Product Url module for generating unique url for commerce products like follows,

For each product it provides id parameter,

  • mycommercesite.com/node/1?id=1
  • mycommercesite.com/node/1?id=2

as well as sku parameter,

  • mycommercesite.com/node/1?sku=pr1
  • mycommercesite.com/node/1?sku=pr2

But I need SEO friendly URL for each product

for example,

  • mycommercesite.com/node/1/product1
  • mycommercesite.com/node/1/product2

Is there any way to do this?

Thanks.

  • There is no pathauto integration? I don't use commerce much, but I was almost sure it integrates... Almost anything does, after all :) – Mołot Dec 2 '14 at 13:28
  • If my answer was useful please consider mark it with the green mark, otherwise anybody is gonna help you in other questions you have. – svelandiag Dec 4 '14 at 15:32
  • any ideas how to achieve this ? – mjs Sep 19 '16 at 11:07
0

the module Commerce product Url is for make unic urls based on product variations, it means when you have one product display showing different product variations.

Check this issue where they explain a little bit better what Im telling you

But there is a non-drupal solution to convert dinamic urls into SEO-friendly urls, that is using mod_rewrite:

EXAMPLE

Sad Original URL = site.com/node/1?id=54

Happy URL :) = site.com/node/1/rueben-sandwich/

Use mod_rewrite in your .htaccess file to parse out the elements of the URL. Like this:

RewriteEngine On //check that in drupal's .htaccess the rewrite engine is on by default

RewriteRule /(.*)/$ node/.*$?id=$1

the (.*) pulls the element out and puts it in variable $1. and the .*$ is just a wildcard that accepts everything after node/

Try it and tell us if it worked because I have not tried it with Drupal websites.

by the way, try to use sku, or some other argument in the url through the module configs, so your url would look better because using "id" the final result of the above code would be /node/1/54

  • Hi Thanks for your post. I can get your idea. But this will not be a permanent solution in my case. – Navane Dec 5 '14 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.