ok let me try once again this link
needs to be redirected to this
[www.zazzle.com/festive_silver_purple_ornament_holiday_cards_postcard-239887577090743570] OR [www.zazzle.com/239887577090743570] (both links are same and work, whichever is simpler to code)
because what I have pinned to pinterest is this
and it shows empty page so what i want is that the people who click on this link
from pinned images at pinterest.com actually get redirected to
[www.zazzle.com/festive_silver_purple_ornament_holiday_cards_postcard-239887577090743570 ] OR [www.zazzle.com/239887577090743570] (both links are same and work, whichever is simpler to code)
is something like this possible?
Thank You so much!
You will be a life saver!

  • 1
    How predictable are these URLs? Is the image id (lack of a better term) always the same number of digits? Does the URL always have _card-? Are they always within the cards directory? Any or all is okay. As long as you have one way to determine the pattern. – closetnoc Feb 17 '15 at 21:13
  • no the number of digits will be changing, each product has different number, i will have to apply the same rule for all my categories, like one for /invitations/ one for /weddings/ i thought if I could figure out one, I could do others, for instance this www.mgdezigns.com/invitations/coral_sunflowers_tea_party_bridal_shower_invites-256702155011593610.html to this www.zazzle.com/256702155011593610 I am somehow having a panicky feeling that this is impossible :( – user2018878 Feb 17 '15 at 21:18
  • 1
    Are you in control of example.com, or is example.com an external URL? – MrWhite Feb 17 '15 at 21:22
  • i am in control of example.com and hence want to edit .htaccess to create some redirect rule, if possible – user2018878 Feb 17 '15 at 21:24
  • Can you edit the question and put in all the /cards/, /invitations/, etc? We can come up with code for you with just that. It may not be a one-liner, but as simple as we can. – closetnoc Feb 17 '15 at 21:26

You could do something like the following in .htaccess to match all the "cards", grabing just the number from the URL:

RewriteEngine On
RewriteRule ^cards/[a-z_]+-([\d]{10,})\.html$ http://www.zazzle.com/$1 [R=301,L]

To add more categories you could be explicit...

RewriteRule ^(?:cards|invitations|weddings)/[a-z_]+-([\d]{10,})\.html$ http://www.zazzle.com/$1 [R=301,L]

Or, be generic, to match anything in the first path segment:

RewriteRule ^[a-z]+/[a-z_]+-([\d]{10,})\.html$ http://www.zazzle.com/$1 [R=301,L]

In fact, you could just match any URL that ends in a hyphen followed by a long number...?

RewriteRule -([\d]{10,})\.html$ http://www.zazzle.com/$1 [R=301,L]
  • and it will not remove the number with each product? just replace www.example.com/cards/by "www.zazzle.com/ " I can try – user2018878 Feb 17 '15 at 21:34
  • It extracts just the number (which must be at least 10 digits). – MrWhite Feb 17 '15 at 21:35
  • tried! but when I go to www.mgdezigns.com/cards/rustic_ribbon_banner_st_patricks_day_card-137070669298455248.html it converts to www.mgdezigns.com/cards/rustic_ribbon_banner_st_patricks_day_card-137070669298455248?title=rustic_ribbon_banner_st_patricks_day_card&pid=137070669298455248 whereas this link remains same, does not get redirected?www.mgdezigns.com/cards/realistic_clovers_pocket_st_patricks_day_card-137618453114920045.html :/ – user2018878 Feb 17 '15 at 21:40
  • i think it is the link , it is showing complete link, removed the h t t p and now working – user2018878 Feb 17 '15 at 21:44
  • 1
    OMG!!!!!!!!!!!!1 IT IS WORKING!!!!!!!!!!!!!! cache clear solve dthe problem!!!!!!!!!1 wow you are AWESOME!!!!!!!!!!! cannot thank you enough!!!!!!!!!!!!!!1 – user2018878 Feb 18 '15 at 13:54

If you want to remove the .html on URLs that otherwise would end in a number, you could use this:

 RedirectMatch permanent /(.*[0-9])\.html$ /$1

Older versions of Apache (before 2.2.6) don't support relative URLs and you would have to use the full URL:

 RedirectMatch permanent /(.*[0-9])\.html$ http://www.zazzle.com/$1
  • trying this too! fingers crossed – user2018878 Feb 17 '15 at 21:34

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.