Jump to content

Rewrite Advice Please


Recommended Posts

I am moving a store over from OSCmax but I would like to set up a 301 rewrite rule to the new urls.

 

Any help would be appreciated.

 

old url

mysite.com/myitem-p-345.html

 

new url

mysite.com/index.php?id_product=345&controller=product

 

Cheers

Steve

Link to comment
Share on other sites

Thanks for that suggestion, it does work but only if i copy that rule for every url I need to redirect as the item desription changes with each url.

 

I would like the rule to grab the number from the url (345 in this case) from the example below and use it in the new url. I have tried using {QUERY_STRING} but i cannot get it to work.

 

old url

mysite.com/jockey-man-gold-top-circulation-socks-p-345.html

 

new url

mysite.com/index.php?id_product=345&controller=product

 

Steve

Link to comment
Share on other sites

Thanks for that suggestion, it does work but only if i copy that rule for every url I need to redirect as the item desription changes with each url.

 

I would like the rule to grab the number from the url (345 in this case) from the example below and use it in the new url. I have tried using {QUERY_STRING} but i cannot get it to work.

 

old url

mysite.com/jockey-man-gold-top-circulation-socks-p-345.html

 

new url

mysite.com/index.php?id_product=345&controller=product

 

Steve

 

i dont quite understand but you should try this one:

 

RewriteRule ^([a-zA-Z0-9\-]+)-p-([0-9]+).html$ http://mysite.com/index.php?id_product=$2&controller=product [R=301,L]

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi

A further question

I am having trouble with this rewrite as well

 

old url

www.mysite.com/product_info.php?manufacturers_id=5&products_id=46

 

new url

www.mysite.com/index.php?id_product=46&controller=product

 

I tried this but it has no effect. Can you let me know whats wrong this?

 

 

RewriteRule ^([a-zA-Z0-9\-]+)products_id=([0-9]+)$ http://www.mysite.com/index.php?id_product=$1&controller=product [R=301,L]

Link to comment
Share on other sites

this should help:

RewriteRule ^product_info.php?manufacturers_id=([0-9]+)&products_id=([0-9]+)$ www.mysite.com/index.php?id_product=$2&controller=product [R=301,L]

 

I have tried this but it does not work because of the ? in the url (mysite.com/product_info.php?manufacturers_id=5&products_id=46))

I have searched the www but no solution I have found appears to work for me.

 

Any other sugestions?

Link to comment
Share on other sites

I have tried this but it does not work because of the ? in the url (mysite.com/product_info.php?manufacturers_id=5&products_id=46))

I have searched the www but no solution I have found appears to work for me.

 

Any other sugestions?

 

ahh so sorry its my mistake, i haven't seen this before :/

 

please, try this rewrite below:

RewriteRule ^product_info.php\?manufacturers_id=([0-9]+)&products_id=([0-9]+)$ www.mysite.com/index.php?id_product=$2&controller=product [R=301,L]

Link to comment
Share on other sites

Thanks for the advice vekia.

 

I have got it to work. I am told the problem is that the url turns into a string after the ? and so RewriteRule does not work without using {QUERY_STRING}. It looks a bit untidy but gets the correct result

 

RewriteCond %{QUERY_STRING} ^products_id=([0-9]+)$

RewriteRule ^index.php$ ../../../../index.php?id_product=%1&controller=product [R=301,L]

Link to comment
Share on other sites

×
×
  • Create New...