最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Change URLs depending on alias

programmeradmin1浏览0评论

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

I was wondering if it is possible to change the urls to posts and pages when there is a request from thealias To make clear: When there is a request from themaindomain, the server returns a page with some links like themaindomain/post1, themaindomain/page1. When there is a request from thealias, the server should return a page with some other links like thealias/post1, thealias/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...

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

I was wondering if it is possible to change the urls to posts and pages when there is a request from thealias To make clear: When there is a request from themaindomain, the server returns a page with some links like themaindomain/post1, themaindomain/page1. When there is a request from thealias, the server should return a page with some other links like thealias/post1, thealias/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 asked Jul 18, 2012 at 17:51 TiesTies 2032 silver badges7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论