N
N
Nebuhad2019-02-16 19:32:29
htaccess
Nebuhad, 2019-02-16 19:32:29

How to properly set up redirects when migrating a site to Wordpress?

It is required to transfer the site to Wordpress from a self-written engine. At the same time, URLs change and you need to set up redirection to new ones (about 20 pcs.).
The old urls look something like this:

http://имя_сайта/dostavka-i-oplata.html
http://имя_сайта/kontakty.html
http://имя_сайта/katalog/kormacat.html

New:
https://имя_сайта/dostavka-i-oplata/
https://имя_сайта/kontakty/
https://имя_сайта/product-category/koshki/suhoj-korm-dlja-koshek/

And all the rest that end in .html should redirect to https://site_name/shop
This option with .htaccess seems to work well:
RewriteRule ^dostavka\-i\-oplata\.html$ /dostavka-i-oplata/? [L,R=301]
RewriteRule ^kontakty\.html$ /kontakty/? [L,R=301]
RewriteRule ^katalog/kormacat\.html$ /product-category/koshki/suhoj-korm-dlja-koshek/? [L,R=301]

What is the best way to proceed and what are the best practices?
1. Whether to edit .htaccess and use Redirect 301 or RewriteRule
2. Maybe just include some plugin for Wordpress.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2019-02-17
@Tolly

It is better to write 20 lines in the file than to install a plugin that litters the database.
If you had nginx, it would probably be easier through a plugin.
Redirect 301 /old/old.php /new/new.php
RewriteRule ^news/new.html /new.html [L,R=301]
are no different, so it doesn't matter
In your example, "\" should be replaced with "/"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question