3

I have a Wordpress multisite and I'm trying to direct everything from one of the sites to a completely different domain. Of the examples I've tried below, none of the redirects seem to do anything.

Options +FollowSymlinks
RewriteEngine on

#attempt one
Redirect 301 ^/multisite-one/.*$ http://newdomain.com/

#attempt two
RewriteRule ^multisite-one/$ http://newdomain.com/ [L,R=301]

#attempt three
RewriteCond %{REQUEST_URI} ^/multisite-one/(.*)$
RewriteRule ^(.*) http://newdomain.com/%1 [R=301,NC]

#attempt four
RewriteCond %{HTTP_HOST} ^multisite-one/$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/ [R=301,L]

#BEGIN Wordpress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

#END Wordpress

A little bit about my setup:

  • The multi site is set up as having 2 homepages, one for multisite-one, another for multisite-two. There is no top level index page.
  • The multisites share page templates. The two sites are structured the same, they just contain different content (i.e. multisite-one is customer service, multisite-two is how-tos)

What I'm looking to accomplish:

http://mainsite.com/multisite-one/ redirects to http://newdomain.com/
http://mainsite.com/multisite-one/page2 redirects to http://newdomain.com/ 
http://mainsite.com/multisite-one/page8/pies redirects to http://newdomain.com/

http://mainsite.com/multisite-two/ does not redirect
http://mainsite.com/multisite-two/page2 does not redirect
http://mainsite.com/multisite-two/page8/tacos does not redirect

I've tried adding the above redirects within the Wordpress code as stated in this similar question. I've also tried all of these that seem relevant.

Note: I cannot use plugins because they are currently disabled and I do not have FTP access. I have to make these updates using the linux command line. Obviously this is a terrible situation.

Community
  • 1
  • 1
itsclarke
  • 8,622
  • 6
  • 33
  • 50
  • If you dont have ftp how are you accessing the .htaccess file? From cpanel? – Ben Rhys-Lewis Feb 04 '16 at 16:28
  • Ok. For your second try one maybe: RewriteRule ^multisite-one/(.*)$ http://newdomain.com/$1 [L,R=301] Remove the $1 near end if you just want all urls to go to newdomain with saving the extensions. But you do want to save extensions right? – Ben Rhys-Lewis Feb 04 '16 at 16:32

2 Answers2

0

There are lots of plugins you could use to help although i prefer to do it myself. I personally use:

Redirect 301  /subsite/  http://newdomain.com/

That works for me moving anything in the subsite folder to the newdomain address but preserving the rest of the URL.

If you want everything in subsite to move to http://newdomain.com/ and lose everything after that in the url then your second one should work

Ben Rhys-Lewis
  • 3,118
  • 8
  • 34
  • 45
  • I think we're close here. This triggered a redirect, but like you said, I want to lose everything after in the url. However my second one did not work. Also, this only worked for pages within `subsite-one/`, but I also need `subsite-one/` root to redirect as well. – itsclarke Feb 04 '16 at 16:35
  • So not this one? RewriteRule ^multisite-one/(.*)$ newdomain.com/ [L,R=301] – Ben Rhys-Lewis Feb 04 '16 at 16:40
  • surprisingly that didn't do anything, but I was able to figure it out after combining several attempts into one. – itsclarke Feb 04 '16 at 16:51
0

Figured it out after more googling and thinking about Ben Rhys-Lewis answer above.

RedirectMatch 301 ^/multisite-one(.*)$ http://newdomain.com/

Community
  • 1
  • 1
itsclarke
  • 8,622
  • 6
  • 33
  • 50