Answer the question
In order to leave comments, you need to log in
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/
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]
Options +FollowSymlinks
RewriteEngine on
rewriterule ^2016/04/05/lpg/(.*)$ http://new-site.ru/lpg/$1 [r=301,nc]
...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.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question