Jump to content
thirty bees forum
  • 0

SEO & URL Redirect Old Product URLs to new Product URLs


Question

Posted

Hello everyone,

I changed my product route in the SEO & URL page of the Back Office to a cleaner and shorter URL.

{category:/}{id}-{rewrite}{-:ean13}.html is what it used to be, but I changed it to {category:/}{rewrite}.html

Now I'm wondering if its posible to make a redirect in the .htaccess file to redirect the old product URLS to the new product URLS.
And ofcourse I don't want to make a redirect for every single product manually.

Does anyone have any clue on how to do this?

Thanks in advance!

  • Like 1

11 answers to this question

Recommended Posts

  • 1
Posted

I dont believe, there is a quick solution. I remember how I did it:

  • You generate all urls with the old structure.
  • Copy them into Excel
  • You generate all urls with the new structure.
  • Copy them into Excel
  • Now you generate in Excel a new column with the correct htacces/nginx redirect.

Maybe somebody has a better solution. Of course you can only achieve it, with some SQL knowledge.

  • Like 2
  • Thanks 1
  • 0
Posted
On 4/17/2019 at 4:54 PM, wakabayashi said:

I dont believe, there is a quick solution. I remember how I did it:

  • You generate all urls with the old structure.
  • Copy them into Excel
  • You generate all urls with the new structure.
  • Copy them into Excel
  • Now you generate in Excel a new column with the correct htacces/nginx redirect.

Maybe somebody has a better solution. Of course you can only achieve it, with some SQL knowledge.

the best solution. I made it this way too to migrate my urls

  • Like 1
  • 0
Posted (edited)

If you want to achieve this in one single line on apache server you can setup a rewrite rule for this in .htaccess file on root directory of the website in order to achieve this : 

" {category:/}{id}-{rewrite}{-:ean13}.html is what it used to be, but I changed it to {category:/}{rewrite}.html "

RewriteRule    ^category/([0-9-]+)-([A-Za-z0-9-]+)-([0-9-]+).html    category/$2.html    [NC,L] 

So this old link :

http://monsite.com/category/548-monurlshorttened-0396076886677.html

will be redirect to :

http://monsite.com/category/monurlshorttened.html

 

I hope it will help others 🙂

Edited by zen
  • 0
Posted

But, maybe it's better for SEO to redirect them to the real url of the category with the dispatcher.php, by using id in that url, avoiding changes of short-links.

Not sure for that, just a suggestion.. waiting to be clarified by someone who knows better about SEO.

 

  • 0
Posted
On 4/17/2019 at 9:54 PM, wakabayashi said:

I dont believe, there is a quick solution. I remember how I did it:

  • You generate all urls with the old structure.
  • Copy them into Excel
  • You generate all urls with the new structure.
  • Copy them into Excel
  • Now you generate in Excel a new column with the correct htacces/nginx redirect.

Maybe somebody has a better solution. Of course you can only achieve it, with some SQL knowledge.

This method works.. but as you have ID in the original link and also short-link.. it possible to avoid this heavy work and overload the htaccess file which is loaded at each connection and refresh of each page, not the best for server performance if you have a lot of categories, if you have only a few one then it's ok to do so.

For products rewrite like this it will make so many lines to include in htaccess, better avoid it whenever you can.

  • 0
Posted
On 4/17/2019 at 4:54 PM, wakabayashi said:

I dont believe, there is a quick solution. I remember how I did it:

  • You generate all urls with the old structure.
  • Copy them into Excel
  • You generate all urls with the new structure.
  • Copy them into Excel
  • Now you generate in Excel a new column with the correct htacces/nginx redirect.

Maybe somebody has a better solution. Of course you can only achieve it, with some SQL knowledge.

 Sorry for this late reaction on this topic, but I've used this solution and for some reason a few of my category names don't match the product url category name.

So this means about 3 quarters of my redirect urls work fine but the other part doesn't redirect the old urls to the new urls.
What module did you use to generate all the urls?

Thanks!

  • 0
Posted

How about making an override to FrontController and handle this with PHP code.

Its less recommended for performance because htaccess/web server comes first, but at least you wont miss anything.

Just parse the url to get the product id and use 301 redirect to new product page.

You can give it a month or two until google stop using the old urls and remove the override after to regain full performance.

  • 0
Posted

Picking up on this old thread.

I'd like to redirect from

https://www.store.com/de/category/super-product

to 

https://www.store.com/de/category/product

I found this tool

https://donatstudios.com/RewriteRule_Generator

that suggests this:

# 301 --- https://www.store.com/de/category/super-product => https://www.store.com/de/category/product
RewriteRule ^de/category/super\-product$ /de/category/product? [L,R=301]

Perhaps helpful for others!
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...