Search code examples
wordpress.htaccesshttp-status-code-301http-redirectmultisite

301 direct a Wordpress multisite


Bear with me while I try to explain what I'm trying to do.

I have recently launched a website which replaces an existing website. They are both WordPress multisites however, the old website has lots of pages while this new website has grouped all those pages onto much fewer pages.

What I need to do is 301 redirect the old site to the new website:

http://website.com/name/section/info

now changes to:

http://website.com/name/section#info

What would I need to add to the .htaccess to achieve this?

In all honesty, I don't know where to start and I'm too afraid to try anything because I don't want to break a live website.


Solution

  • You can use this redirect rule as your first rule:

    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([\w-]+/[\w-]+)/([\w-]+)/?$ /$1#$2 [L,NE,NC,R=301]