Hello.

Tell me how to make a 301 redirect in this case: with

site.com/OLD_category_name/item/page.html 

on

 site.com/NEW_category_name/item/page.html 

Those. The site names have changed the categories (all), and the final pages are generated through the category. For the pages with the categories themselves, we set up the redirect:

 Redirect 301 /OLD_category_name.html http://site.com/NEW_category_name.html 

But how to set up a redirect for pages with articles?

I would be very grateful for the help.

    2 answers 2

     RewriteEngine on RewriteBase / RewriteRule ^OLD_category_name/(.*) http://www.example.com/NEW_category_name/$1 [R=301,L] 
    • Thank. It helped. - Vladimir
    • The question arose along the way. In the version that you gave above it will be like a 301 redirect to work or just a normal redirect? - Vladimir
    • As 301 redirects are moved all the time, that is, everything is OK for search engines, they will state that the indexed URL has changed. - labris
    • Ok, thanks for the help. - Vladimir
    • We decided to do a similar operation with the site that works through https and came across a server error. The redirect was done like this: RewriteEngine on RewriteBase / RewriteRule ^OLD_category_name/(.*) http://example.com/NEW_category_name/$1 [R=301,L] Redirect 301 /OLD_category_name.html http://example.com/NEW_category_name.html - Vladimir

    The situation is this.

    With your proposed option:

     # First rewrite any request to the wrong domain to use the correct one (here www.) RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ %{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite to HTTPS: RewriteCond %{HTTPS} OFF RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

    work only home. Those. when trying to go to the category page

     http://example.com/NEW_category_name.html 

    writes a mistake.

    Earned with this option:

     RewriteCond %{HTTP_HOST} ^www.example\.com$ [NC] RewriteRule ^(.*)$ https://example.com/$1 [R=301,L] 

    Normally redirect from "www" to without "www". Redirects from old categories to new ones also work fine. Those. this:

     Redirect 301 /OLD_category_name.html http://example.com/NEW_category_name.html 

    But this rule does not work:

     RewriteBase / RewriteRule ^OLD_category_name/(.*) http://example.com/NEW_category_name/$1 [R=301,L] 

    Those. what the question actually began does not work ...