Y
Y
Yuri2015-11-20 21:05:53
Programming
Yuri, 2015-11-20 21:05:53

How to make a massive 301 redirect from /%postname%.html to /%category%/%postname%.html in Wordpress?

How to make a massive 301 redirect from /%postname%.html to /%category%/%postname%.html in Wordpress?
There is a need to move from the /%postname%.html structure to /%category%/%postname%.html Do you need a mass redirect? Without any excels, only the necessary code and where to insert it?. I beg you to help?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew B., 2015-11-21
@seowind

If it's just that, then no. It would be the other way around - it would be easier, but you can only programmatically determine which category the post belongs to, and you also need to programmatically substitute the name of the category in the URL and at the same time, so that the entrance to the old URL gives 301. You just can’t get off with the code, you need a module /plugin...
The second option - handles using a ready-made plugin, like this one - redirection

S
ShamblerR, 2015-11-21
@ShamblerR

RewriteCond %{REQUEST_URI} ^(.*)/dir1/(.*)$ 
# если строка содержит /dir1/ 
RewriteRule ^(.*)$ %1/dir2/%1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question