Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
Wesley

SEO & URL Redirect Old Product URLs to new Product URLs

Question

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!

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 1

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 1
  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0
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

Share this post


Link to post
Share on other sites
  • 0

Couldn't find anything else so I used your solution. Thank you!

Share this post


Link to post
Share on other sites
  • 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

Share this post


Link to post
Share on other sites
  • 0

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.

 

Share this post


Link to post
Share on other sites
  • 0
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.

Share this post


Link to post
Share on other sites
  • 0
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!

Share this post


Link to post
Share on other sites
  • 0

I didnt use any module. I coded it something back then.

But how are some of your urls wrong? What is your url scheme?

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites

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

×