WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two domain names: themaindomain.com and thealias.com. Wordpress is located under themaindomain.com.

I was wondering if it is possible to change the urls to posts and pages when there is a request from thealias.com To make clear: When there is a request from themaindomain.com, the server returns a page with some links like themaindomain.com/post1, themaindomain.com/page1. When there is a request from thealias.com, the server should return a page with some other links like thealias.com/post1, thealias.com/page1. So the two domains point to the same blog, but depending on the request url it changes the links.

Is this possible and if it is, how?

Thanks a lot...

share|improve this question

closed as off topic by Chris_O, Brian Fegter, EAMann Jul 18 '12 at 20:12

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

You can use the the WP_HOME directive in your wp-config.php. Just set it dynamically based on $_SERVER['HTTP_HOST'] like the example in the codex.

define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

You might also want to define WP_SITEURL in the same way. I do something like the above for the wp-content url on one of my sites:

define('WP_CONTENT_URL', '//' . $_SERVER['HTTP_HOST'] . '/content');

All that said, the SEO in me is screaming that this is a terrible idea -- duplicate content and such. Much better to have a single site and redirect the alias to the canonical site.

share|improve this answer
About that SEO, you're right, I guess. I haven't thought that much about it. Thank you anyway. – TV productions Jul 18 '12 at 21:25

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