A
A
Aleksandr Kovalev2018-10-04 20:47:55
WordPress
Aleksandr Kovalev, 2018-10-04 20:47:55

How to make a 301 redirect from the list of pages to the main one?

There was a site on wordpress with a bunch of posts, they were gone, there was only a list of links, how to make a redirect in bulk from this list (~1000 lines)? Help implement...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2018-10-05
@azerphoenix

Hello!
Easiest option:
1) open this list in your favorite editor (Sublime Text3 or NotePad++)
Suppose the list looks like:

example.com/link1
example.com/link2
example.com/link3
2) Using regex, add the following code to the beginning of each line:
I will use the example of Sublime Text 2
ctrl + shift + h (search and replace).
Search - ^
Replace - Redirect 301 (don't forget the space after 301)
3) open the search and replace panel again
Search - $
Replace - / (don't forget the space at the beginning before the slash).
This will make your links look like this:
Redirect 301 http://example.com/link1 /
Redirect 301 http://example.com/link2 /
Redirect 301 http://example.com/link3 /

And then just add this code to your site's htaccess file. Of course, you can do this with regex in one pass, but for clarity, I provided the above code.
And in order to do it in one pass, then do the following:
open the search and replace panel and type the following regex:
Search - (.*)
Replace - Redirect 301 $1 /
Also, if you have the Yoast SEO plugin installed in your VI, then it has the ability to import redirects from the htaccess file. To do this, simply copy the list you received earlier, paste it into the import window and click import.
+ you can use a bunch of ready-made plugins, with the ability to bulk import
1) https://wordpress.org/plugins/simple-301-redirects...
supports CSV import

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question