0

I'm about to move my online store website from X-Cart to Wordpress Woocommerce. I need a 301 redirect to direct all the old product pages to the new ones so I don't lose out on SEO.

The old pages were www.mysite.com/product-with-11.5inch-something.html The new ones are www.mysite.com/product/product-with-11-5inch-something/

Basically all .html pages have any . in them replaced with a - and the .html dropped from the end of the URL. Then they now site in a /product/ folder.

Can anyone help me out with a rule to do all of these in one go in htaccess? I can put a single line in there with a 301 redirect but there are over 6000 products so will be a huge list!

Lee
  • 1
  • 1

1 Answers1

0

I'd suggest using a crawler to find all the URLs of the website, exporting it into excel or a similar tool and then replacing them using excel formulas.

A formula like this will do the job (just remove the domain first, substitute it with an empty string):

=CONCATENATE("/product/",SUBSTITUTE(SUBSTITUTE(A1,".html",""),".","-"))

Instead of using a crawler, you can also use Google Analytics, Google Search Console or majestic.com to find important URLs of your old website.

Moz has a good article on this despite being a little old:

https://moz.com/blog/web-site-migration-guide-tips-for-seos

Look at phases 2 and 3 of the article

The other solution would be using mod_rewrite module of your Apache server. You can write rules but then everything will be forwarded to the /product/ directory. You need to specify extra conditions to prevent other pages of your website from redirecting.

Mehdi
  • 186
  • 2
  • 8