I have an old site www.exemple.com and I made a new one name www.example.ro The thing is, the old site (and the new one) are Woocommerce shops and have a lot of products. Is there any method to perform this redirects automatically? Or at least to configure all of them at once? If so, how? Thank you!

  • Are the new site and old site in the same structure? – simongcc Apr 27 at 8:23
  • The product names are the same. I have to change the URL before products, but that's not the main problem. I think I will use Redirections plugin on the old site and setup the following rule: Source URL: example.com Query Parameters: "Ignore & pass parameters to the target" Target URL: example.ro That will direct all traffic from the .com to the .co. – Robert Apr 27 at 8:41
  • If your http server is apache you can use redirect either in .htaccess or in the <virtualhost> block - "Redirect 301 / example.ro" or for nginx within server block "return 301 example.ro$request_uri;" – Admiral Noisy Bottom Apr 27 at 8:49

You didn't mention what http server you are using so I'll assume it is either Apache or Nginx.


The most efficient method would be to include a "redirect" statement within the block;

<VirtualHost your_ip_address:80>

ServerName example.com
ServerAlias www.example.com

Redirect 301 / https://example.ro/


By doing it within your httpd.conf the work is done prior to any site resources being served. It will effectively take all traffic for example.com to example.ro as soon as it is requested.

Another method, again for Apache, is via the .htaccess file. This method requires you place a .htaccess file into each sub-directory because URLs like example.com/wp-admin would still succeed without redirection.

Your .htaccess in the root folder for your domain needs the following added.

Redirect 301 / https://example.ro/

After modifying Apache's config restart it and the changes will be effective immediately.


Nginx is just as simple although it does not support .htaccess files. The redirection is performed within the Server block.

For example;

server { listen your_ip_address:80; server_name example.com www.example.com;

return 301 https://example.ro$request_uri;


Reload Nginx and the redirection will become active.

Browser Cache

Clear your browser cache otherwise you might have issues. Google Chrome drives me mental when I make a change and it doesn't care until I clean the cache, curse & swear at it and try again.

I hope this helps someone.

| improve this answer | |
  • Thank you for your answer! My sites are not really in the same structure. How should I proceed in order to resolve this? Change the structure of the new site? – Robert Apr 27 at 9:32
  • For the method I suggested they don't need to be in the same structure. To verify it worked I did a redirect from one url to another for one of my sites and it worked perfectly. Although they were both on the same server they were completely different and separate domains. It should work for you. – Admiral Noisy Bottom Apr 27 at 9:44
  • Yes, the method works. But let's assume that I have something like this: oldwebsite.com/products/jeans/product-name new website.ro/example/jeans/product-name Product names are the same in most cases. I want this because when people are googling the website, I don't want just to be redirected to the new site. I want them to be redirected to the same page as structure, but in the new site. – Robert Apr 27 at 9:50
  • I'm sorry, I misunderstood. I'm not an expert on .htaccess files but I believe it will do a rewrite & redirect as you require. For example, example.com/products/air-guitar-with-case becomes example.ro/products/air-guitar-with-case. Is that closer to what you're asking? – Admiral Noisy Bottom Apr 27 at 9:55
  • Are you nginx or apache? The nginx option I offered does exactly what you want I believe because it only changes the domain, the rest of the url remains the same. – Admiral Noisy Bottom Apr 27 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.