I want to setup a single wordpress install to allow users to visit using 2 domains:

For example:



I can do this for the most part, but whatever domain is configured in the wp-admin screen, it will redirect to that whenever any of the links are clicked.

For example, if I set it up to foo.com and I come in using bar.foo.com and click an article link, it takes me to foo.com and the article link. I want the user to stay on the domain they came in.

migrated from stackoverflow.com Jan 1 '10 at 3:14

This question came from our site for professional and enthusiast programmers.


It depends. Do you want one domain to redirect to the other, or do you want the same content available on both domains?

For the former, just use a rewrite rule to permanently redirect the first domain to the second domain. It's important that you use a permanent redirect (301) or Google will penalize you for duplicate content:

RewriteCond %{HTTP_HOST} ^myfirstdomain\.com$
RewriteRule (.*) http://myseconddomain.com$1

The latter is much harder because WordPress expects a "main" domain for each blog, and it's not something you would want to do for SEO reasons because Google will see two pages that are exactly the same in two different spots.

You can map multiple domains to the same blog but WordPress will always redirect them to the primary domain.

You can proxy the requests from bar.foo.com to foo.com (just don't map bar.foo.com in WordPress):

RewriteCond %{HTTP_HOST} ^myfirstdomain\.com$ RewriteRule (.*) http://myseconddomain.com$1 [P,L]

I've never tried this so it might not work without problems. Either way, it's a really bad idea to do this for so many reasons.

  • latter, dont mind the seo hit. – Joelio Dec 31 '09 at 21:46
  • Formatting doesn't work in comments? That blows. Will repost in a separate answer. – Foofy Jan 1 '10 at 0:29

Well, I tried rewriting above and it didnt work so well, but this seemed to work pretty well:

Go to plugins folder and create a file with this in it:

Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/

remove_filter('template_redirect', 'redirect_canonical');


Enable the plugin, then wala, it works!


No coding necessary! Simple install http://wordpress.org/extend/plugins/domain-theme/ and everything (domains and subdomains and different theme options per domain) are taken care of! Enjoy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.