Laravel / Multi-TLD的主机设置 [英] Laravel / Host Setup for Multi-TLD

查看:106
本文介绍了Laravel / Multi-TLD的主机设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我已经写了5遍了,仍然不知道如何正确地问,所以就这样...

Basically Ive written out this about 5 times, still dont know how to properly ask, so here goes...

我想要两个域,例如我已经注册的example.net example.info 。我希望他们指向我正在构建的一个应用程序,然后希望使用Laravel将两个不同的域路由到自己的页面上……这是我尝试过的,遇到了哪些问题...

I want two domains, say example.net and example.info which I have registered. I want them to point to the one application I'm building, then hopefully use Laravel to route the two different domains to there own pages... here is what I've tried and what problems I've ran into...

**#1域转发**

** #1 Domain Forward **

将我的应用程序上传到example.net并转发了.info域到.net域。然后尝试...

Uploaded my app to example.net and forwarded the .info domain to the .net domain. And then tried...

Route::group(array('domain' => 'example.info'), function()
{
    Route::get('/', function(){ return 'INFO PAGE!'; });
});

Route::group(array('domain' => 'example.net'), function()
{
    Route::get('/', function(){ return 'NET PAGE!'; });
});

Route::get('/', 'HomeController@index');

问题


  1. Laravel域路由似乎无法识别没有子域的域,例如'{subdomain} .example.net'将起作用,但是'example.net'和'example.info'不会起作用吗?

  1. Laravel Domain Routing doesnt seem to recognise domains without subdomains, eg '{subdomain}.example.net' will work, but 'example.net' and 'example.info' wont?

在域转发时, HTTP_HOST 将始终显示 .net 和不是 .info ,因此不能在路由文件中使用 if switch 语句

When domain forwarding, the HTTP_HOST will always show .net and not .info, so cant use if or switch statement in the routes file

替代解决方案

我能想到的唯一解决方案是使用主机的共享主机设置来拥有两个单独的站点,每个站点都指向它们指向适当的域,并将我的IDE设置为同时上传到两个站点?

The only soloution i can think of is to use my host's shared hosting setup to have two individual sites, each with the appropriate domains pointing to them and set my IDE to upload to both sites?

肯定有更好的方法吗?

任何帮助都很好,这对我来说还很新,所以如果您能保持简单,谢谢... jimmy

Any help would be great, also Im pretty new to this so if you could keep it simple please, thanks... jimmy

推荐答案

谢谢对于回复人员,这就是我最终要做的...仅将路线放入变量并将其传递给路线组,似乎对我有用

Thanks for the replies guys, this is what i ended up doing... just putting the routes into variable and passing it to route groups, seems to work for me

$frontendRoutes = function()
{
    Route::get('/', function(){
        return 'Index Page';
    })
};

Route::group(['domain' => 'example.net'], $frontendRoutes);
Route::group(['domain' => 'example.info'], $frontendRoutes);

这篇关于Laravel / Multi-TLD的主机设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆