Adam Wassall
asked on
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.
Here is what I am trying to do (the stuff in {} are variables)
I need to change the product url from
/product/{Category-Name}/{
I need the Category URL to change from
/ecategory/{Category-ID}/{
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.
ASKER
Hi
This gives me an internal server error. I have tried it without the " and same.
Thanks
This gives me an internal server error. I have tried it without the " and same.
Thanks
Can you post line from error log?
ASKER
sure. Here it is
[Fri Jul 17 22:48:35.072132 2015] [core:alert] [pid 32062] [client 82.38.158.235:65201] /home/dwasep/public_html/.htaccess: RewriteRule: cannot compile regular expression '^/?(product|ecategory|manu)/([^\\/]+)/(.+?)\\.html)$'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Parentheses dont match
And "redirect with variable" should be temporary.
And "redirect with variable" should be temporary.
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
It looks like what you need to do is simply eliminate these components from the original paths?/product/{Category-Name}
/ecategory/{Category-ID}
/manu
This would seem to imply that there will never be a collision on any subset of the existing /product, /ecategory or /manu paths, right?
ASKER
Great that worked brilliantly. Thank you.
Open in new window