I have an old site www.exemple 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!
I have an old site www.exemple 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!
Share Improve this question asked Apr 27, 2020 at 7:24 RobertRobert 1 3- Are the new site and old site in the same structure? – 西門 正 Code Guy - JingCodeGuy Commented Apr 27, 2020 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 Query Parameters: "Ignore & pass parameters to the target" Target URL: example.ro That will direct all traffic from the to the .co. – Robert Commented Apr 27, 2020 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 Commented Apr 27, 2020 at 8:49
1 Answer
Reset to default 0You didn't mention what http server you are using so I'll assume it is either Apache or Nginx.
Apache
The most efficient method would be to include a "redirect" statement within the block;
<VirtualHost your_ip_address:80>
ServerName example
ServerAlias www.example
Redirect 301 / https://example.ro/
</VirtualHost>
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 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/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
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 www.example;
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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744528674a4579012.html
评论列表(0条)