开发者

domains redirecting to specific pages

I have a main domain name associated with a WordPress site, and then I have a coup开发者_运维问答le other domain names connected to that site as well.

I want the other two domains names to point/redirect to specific pages on the site rather than the index page, which is the default.

So when domain1.com is typed into the browser, it goes to maindomain.com/domain1page/ (this is how the permalinks are set up). Is this possible?


Add this to index.php and upload it the root of domain1.com

<?php
    header("location:http://maindomain.com/domain1page/");
?>

OR if you do not have a Hosting package for domain1.com go to the Domain Manager and in Nameservers you can enter a URL to redirect your domain to there.


It's possible, but you must add each domain manually. Just redirect them to your page.


Sure - there are lots of different ways to do this. Some registrars let you set up redirects at the domain level. You could also have a website set up for each domain on your server, and then just redirect to the page you'd like from that. You could also use the httpd.ini file to detect the domain and redirect to the appropriate page.


This is a small script that might serve the purpose.

You should place this at the top of header.php in your wordpress theme.

The script will not do anything if a domain is not matched so wordpress will load normal page. Haven't tested, but it should work.

<?php
$host = $_SERVER["HTTP_HOST"];    

//Setup Domains Directory Names Here
$domain1 = 'domainname1.com';
$domain1_dir = 'domain1directoryhere';
$domain2 = 'domainname2.com';
$domain2_dir = 'domain2directoryhere';
$domain3 = 'domainname3.com';
$domain3_dir = 'domain3directoryhere';

//Redirects to directory depending domain.
switch (true){
 case (preg_match("/$domain1/",$host)):
 header("location:/$domain1_dir");
 break;

 case (preg_match("/$domain2/",$host)):
 header("location:/$domain2_dir");
 break;

 case (preg_match("/$domain3/",$host)):
 header("location:/$domain3_dir");
 break; 
}
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜