在单个网站上加载多个域

时间:2019-06-12 16:42:29

标签: codeigniter dns uri

我有多个域

mysite.com - Main website

其他域

test.com
book.com
aaa.com

...

我有一个基于Codeigniter的网站 我想在该地址上加载其他域

test.com (mysite.com/seller/test)
book.com ( mysite.com/seller/book)
aaa.com (mysite.com/seller/aaa)

我在卖家网站上有这些页面

test.com/about 
test.com/contact
test.com/shop

正在加载此页面

mysite.com/seller/test/about

实际上就是这样

test.com/about (mysite.com/seller/test/about)

我在Routes.php上有这个

$route['default_controller'] = "index";
$route['404_override'] = 'index/lost';
$route['translate_uri_dashes'] = FALSE;
$route['seller/(:any)/product/detail/(:num)'] = 'seller_product/detail/$2';
$route['seller/(:any)/(:any)'] = 'seller/$2/$1/';
$route['seller/(:any)/(:any)/(:num)'] = 'seller/$2/$1/$3';
$route['seller/(:any)'] = 'seller/index/$1';

希望您能理解我要做什么 谢谢您的帮助

1 个答案:

答案 0 :(得分:0)

我希望它对您有用。将所有域路径设置为网站的根目录。并在您的route.php文件中进行这些更改

switch ( $_SERVER['HTTP_HOST'] ) {
    case 'test.com':
        $route['default_controller'] = "seller/test";
        $route['(.*)'] = "seller/test/$1";
    break;
    case 'book.com':
        $route['default_controller'] = "seller/book";
        $route['(.*)'] = "seller/book/$1";
    break;
    case 'aaa.com':
        $route['default_controller'] = "seller/aaa";
        $route['(.*)'] = "seller/aaa/$1";
    break;
    default:
        $route['default_controller'] = "index";
    break;
}