Multiple domains on the same WordPress site - wordpress

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]

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' );

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.

Related

301 Redirect Not Working .htaccess

I have the following redirect code in my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301,NC]
</IfModule>
# END WordPress
AddHandler php-stable .php
I'm trying to redirect all traffic from olddomain to newdomain. Not that the new domain does use "www".
When clicking on an old link elsewhere on the net that would refer to a post, redirect does seem to happen but it does not add in the correct slash after the domain name.
Here is what happens, the link to my old domain is as such on a website (just posted by someone):
http://olddomain.com/some-blog-post/
When I click on that link in a browser, it actually opens up:
http://www.newdomain.comsome-blog-post/
The slash between the domain and the blog post is missing.
Also, if it helps I'm using MediaTemple as my host for the old domain and I'm modifying my .htaccess file in
domains/olddomain.com/html/.htaccess
Anyone have any idea out there? Thanks a ton, I'm stuck.
Ok I just checked on this a little more and it turns out everything is working fine with the .htaccess code I pasted above.
My web browser was caching aggressively and I just had to dump the cache (or use private browsing).
See here for more debugging tips:
Tips for debugging .htaccess rewrite rules
maybe this is better:
RewriteCond %{HTTP_HOST} ^(.*\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ http://%1newdomain.com/$1 [R=301,L]
It matches both the subdomain and request URI and merges them with the new domain. If there is no subdomain, it proceeds to match the request and will redirect without a subdomain.

.htaccess Domain redirect conflicts with addon-domain

I have a wordpress blog "old.com" hosted in shared hosting where "old.com" is the main domain...
Then decide to redirect this "old.com" to "new.com" (an addon domain hosted in same hosting)...
I use this code on .htaccess
Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$
http://new.com/$1 [R=301,L]
Everything works just fine. I also have an addon domain, "addon1.com" and I still can access this perfectly (I added this "addon1.com" before I redirected "old.com" to "new.com)"
The problem now is, I add "addon2.com" (another addon domain), but I can't access this domain... When I try to access this "addon2.com", it will redirect me to old.com/hxxp://addon.com and shows that the page can't be found....
Can somone help me how to solve this problem? If I remove the redirect code from .htacess, my addon2.com works just fine...
Thanks
Andi
edited
i added this on my .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www.)?addon2.com
RewriteRule (.*) hxxp://new.com/$1 [R=301,L]
and it seems like it works :)

redirect from one domain to another but keep requested page

I want to create a redirect for one of my domains to another.
I followed what reported in this question, and it works just fine.
The problem I'm having now is that I want to redirect www.example.com/some-page to
www.new-example.com/some-page.
Right now, www.example.com/some-page just redirects to www.new-example.com, this could be confusing for users who created bookmarks to some parts of the website.
Both URLs link to the same webhosting, and I'm running a litespeed server.
Add the following to your .htaccess file:
RewriteCond %{HTTP_HOST} !^yourdomain.com [NC]
RewriteRule ^ http://yourdomain.com%{REQUEST_URI} [L,R=301]
Edit: yourdomain.com should be the domain you wanna redirect to.

How do I modify my .htaccess file to redirect a URL for one domain only, and not rewrite other domains hosted by the same server

I switched blogging software (MT to WordPress) on a site and need to redirect requests to http://www.domain1/atom.xml to http://www.domain1.com/feed/atom.
I was using a simple Redirectmatch rule, but realized that it was also redirecting requests made to another site (domain2), that is is hosted by the server, in a subdirectory of domain1, which I do not want to happen (its feed is still at http://www.domain2.com/atom.xml).
How do I get the redirect to only occur for domain1?
I was trying to do the following, but it didn't work.
RewriteCond %{HTTP_HOST} ^www\.domain1\.com [NC]
RewriteRule ^/atom\.xml$ http://www.domain1.com/feed/atom [L,R=301]
Am I close?
Thanks,
Rich
If you don't do any rewriting for domain2 then a quick fix would be to create a .htaccess file inside its root folder and disable rewriting with RewriteEngine off.
Otherwise you are on the right path with the RewriteCond, it should do the trick. Have you tried adding $ at the end (RewriteCond %{HTTP_HOST} ^www\.domain1\.com$ [NC]) / any misspelling / www. vs no www.?
I figured it out, but I'm not sure why exactly this works. I moved my .htaccess to be:
RewriteCond %{HTTP_HOST} ^www\.domain1\.com [NC]
RewriteRule ^atom\.xml$ http://www.domain1.com/feed/atom [L,R=301]
I removed the slash in front of "atom" in the RewriteRule.
I would think I should have the slash, as I'm tyring to redirect http://www.domain1.com/atom.xml .
It's at the root of the domain...
Oh well. Can anyone explain why this works? Is the string passed to the pattern matching not contain the starting slash?
Thanks,
Rich

Using .htaccess to redirect a domain to another URL

I have a site running wordpress, it's the full site. One of the pages is like a contact-us form located at www.ourdomain.com/contact-us/
I also have a URL like contactourdomain.com and I want it to redirect to www.ourdomain.com/contact-us/
We used to do this with a redirect on network solutions, but I prefer to have it all done right on the server if possible. I've got it sort of working but when you visit the link is still says contactourdomain.com/contact-us/ as the URL, and that breaks all the other ones.
Any suggestions?
.htaccess
Options -MultiViews
RewriteEngine on
RewriteBase /
# Rewrite
RewriteRule ^(.*)$ http://www.ourdomain.com/contact-us//$1 [L]
if you add this in .htaccess is it working?:
RewriteRule ^$ contact-us/ [R=301,L]
keep me posted..

Resources