S
S
Sid_Sidorenko2016-04-18 19:44:52
Apache HTTP Server
Sid_Sidorenko, 2016-04-18 19:44:52

How to properly redirect with the mod_rewrite directive in WordPress?

Hello!
Tell me, please, how to properly set up redirects from the old site to the new one on each individual page?
For example, from site.ru/2016/04/05/lpg
to
new-site.ru/lpg
No date!!!
Site on WordPress. Moved the site to a new domain. Already on the new site, I changed permalinks from new-site.ru/2016/04/18/sample-post to new-site.ru/sample-post/. That is, I removed the date.
And a problem arose: a redirect from the site.ru/2016/04/05/lpg page leads to a page like this new-site.ru/2016/04/05/lpg.
And this, of course, is the 404 page.
I tried this:

Redirect 301 http://site.ru/2016/04/05/lpg/ http://new-site.ru/lpg/

So:
RewriteEngine on RewriteCond %{HTTP_HOST} ^site.ru/2016/04/05/lpg/$ [OR] RewriteCond %{HTTP_HOST} ^www.site.ru/2016/04/05/lpg/$ RewriteRule ^/?$ "http://new-site.ru/lpg/" [R=301,L]

And so too:
Options +FollowSymlinks
RewriteEngine on
rewriterule ^2016/04/05/lpg/(.*)$ http://new-site.ru/lpg/$1 [r=301,nc]

Does not work.
If I return permalinks on the new site to the form with the date new-site.ru/2016/04/18/sample-post , then everything falls into place. But I don't need that. I want to remove the date.
The hoster replied that somehow this should be done in .htaccess using the mod_rewrite directive.
Here is his answer:
...we recommend that you explore alternative redirection options on the Web using mod_rewrite directives, familiarize yourself with the "Multisite" function in the WordPress CMS, and also familiarize yourself with the functionality of the "Sites" section, where it is possible to link another domain as a mirror to the site directory.

Why do I need multisite?
If you can help me, I will be very grateful!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question