mardi 4 juillet 2017

Laravel 5.1 group routes for specific domains and all subdomains

So I have a project with multiple domains pointing to it. Now I want to group routes by domains and subdomains.

For example I want to have separate routes for example.com and every subdomain of example.com

I do this right now like this:

$RoutesOnlyForExamp = function() {
 // MY ROUTES
};

Route::group(['domain' => 'sub1.example.com'], $RoutesOnlyForExamp);
Route::group(['domain' => 'sub2.example.com'], $RoutesOnlyForExamp);
Route::group(['domain' => 'example.com'], $RoutesOnlyForExamp);

Now I have a weired problem. I have some links in my view which all lead into a

return view('xyz');

Now let's say I access the site via sub1.example.com. Now some of my links look right, like this:

<a href="http://ift.tt/2slPOVm">Random Link 1</a>

But some look like this, which is wrong because I am on sub1.example.com and not example.com:

<a href="example.com/slug">Random Link 1</a>

And I don't see any pattern when and why it takes the wrong domain. My goal is that if I access the site via sub1.example.com all links should take this and not just example.com.

I hope the problem is clear. Otherwise I can try it with more detail.

I appreciate any help and thank you in advance!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire