Andrei Surdu
Andrei Surdu

Reputation: 2341

Multiple domains on the same WordPress site

I have a Wordpress site runing on Apache and now I want to add another domain adress to this site. In a few words here... I have two domain names domain1.com and domain2.com . domain1.com is set and the website is working as it should but now I want to add another domain for the same site. domain2.com, must be redirect to domain1.com, the problem is that I have no idea why it doesn't work, because when I try to access domain2.com it open the following address.

http://domain1.com/wp-signup.php?new=domain2.com

Basically this is a redirect to default domain on signup page. What should I do to fix this? Hope you understood the question, I don't know how to explain it better.

Edit: I've added the following rules in .htaccess and restarted apache, but the problem persists. Maybe is something from Wordpress?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)domain2.com [NC]
RewriteRule ^(.*)$ http://domain1.com/$1 [R=301,L]

Upvotes: 0

Views: 1510

Answers (2)

Andrei Surdu
Andrei Surdu

Reputation: 2341

OK, looks like all this is wordpress related and apache(htaccess) have nothing to do here. The solution that works for me: I've added this line in wp-config.php and now it works great. Now if I access domain2.com it is redirected to domain1.com, exactly what I wanted. :)

define( 'NOBLOGREDIRECT', 'http://domain1.com' );

Upvotes: 1

melb23
melb23

Reputation: 1

This is what I use for my 301 redirects:

RewriteCond %{HTTP_HOST} ^domain2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain2.com$
RewriteRule ^(.*)$ "http\://www.domain1.net/$1" [R=301,L]

This redirects the domain whether or not people type in the www. part of the url. The backslashes (\) escape the punctuation.

Hope this helps.

Upvotes: 0

Related Questions