0

i have to redirect many urls

the structure is this:

OLD URL

/category/product-18-name.aspx

NEW URL

product18name.php (is merely an example)

i wish to do a regex, if a user type /anyword/product-18-name.aspx i wish that user will go to product18name.php

in short, i wish that the word in the middle of 2 first slashes, example: /category/ that maybe a real category or any word to go to right page

so a user that type: /helloworld/product-18-name.apsx goes to product18name.php or /sdjfkskfdns/product-18-name.apsx goes to product18name.php

Now my .htaccess is full of 301 redirects, like

Redirect 301 /electronic/peacemaker2_a5f89948-9f15-4606-9d5c-051d84a4c070.aspx http://www.site.com/product.php?id_product=23580

any help ? thanks

1

A rewrite rule to rewrite any-directory/product-18-name.aspx to product18name.php may look like this

RewriteRule ^(.*)/product-18-name.apsx /product18name.php

  • Correct rule: RewriteRule ^(.*)/product-18-name.apsx http://www.site.com/product18name.php [R=301,NC,L] works like a charm! For example: www.site.com/dhusjeufhu-gjurhgr--egjrh/product18.aspx redirect correctly to www.site.com/product18.php – ienabellamy Sep 28 '12 at 15:43
  • Im happy you did it :) – Hex Sep 28 '12 at 17:26

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.