Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

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.

1 Answer

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.

<?php
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:

<?php
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
add comment

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