Permanent redirect with variables

I need some help - I am switching to a new system with my ecommerce website but this system has a new URL structure. I really want to be able to redirect the old pages to the new ones. I have too many pages to do it manually with 301 redirects so wanted to know if it would be possible to do with redirects with variables. If anyone can help me I will be in your debt.

Here is what I am trying to do (the stuff in {} are variables)

I need to change the product url from

/product/{Category-Name}/{URL}.html to /{URL}.html

I need the Category URL to change from

/ecategory/{Category-ID}/{URL}.html to /{URL}.html

and the manufacturers URL to change from

/manu/{URL}.html to /{URL}.html

So I think I will need to use the RewriteRule but I am not sure about the variables.

Any help will be very appreciated.
Adam WassallAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RewriteEngine on
RewriteRule   "^/?(product|ecategory|manu)/([^\/]+)/(.+?)\.html)$"  "/$3.html"  [R=301,L]

Open in new window

Adam WassallAuthor Commented:

This gives me an internal server error. I have tried it without the " and same.

Can you post line from error log?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Adam WassallAuthor Commented:
sure. Here it is

[Fri Jul 17 22:48:35.072132 2015] [core:alert] [pid 32062] [client] /home/dwasep/public_html/.htaccess: RewriteRule: cannot compile regular expression '^/?(product|ecategory|manu)/([^\\/]+)/(.+?)\\.html)$'

Open in new window

My apologies.  I accidentally left a trailing close-parenthesis to the left of the $, leaving the regex unbalanced.  It should have been:
RewriteEngine on
RewriteRule   "^/?(product|ecategory|manu)/([^\/]+)/(.+?)\.html$"  "/$3.html"  [R=301,L]

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Parentheses dont match
And "redirect with variable" should be temporary.
Ray PaseurCommented:
Just to be clear, it appears that all of the original paths need to be rewritten like this:
FROM...                                TO...
/product/{Category-Name}/{URL}.html    /{URL}.html
/ecategory/{Category-ID}/{URL}.html    /{URL}.html
/manu/{URL}.html                       /{URL}.html

Open in new window

It looks like what you need to do is simply eliminate these components from the original paths?

Open in new window

This would seem to imply that there will never be a collision on any subset of the existing /product, /ecategory or /manu paths, right?
Adam WassallAuthor Commented:
Great that worked brilliantly. Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.