Jess McKenzie Jess McKenzie - 2 months ago 9
PHP Question

Sub Domain Route Not Working

In my

web.php
I have the following route set up. What I was wanting to know is there something specific that I need to follow to get a sub domain of a sub domain to work?

The domain I am using is blah.blah.domain.tld

web.php:

Route::group(['domain' => '{blah}.blah.domain.tld'], function (){

Route::get('', 'DealsFrontEnd@index' );

});


Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class DealsFrontEnd extends Controller
{
public function index()
{
return view('front.deals');
}
}

Answer

Too long for a comment: Try using a closure for debugging:

Route::group(['domain' => '{blah}.blah.domain.tld'], function (){

    Route::get('', function() {
        echo "Hello World";
    });

});

Make sure you have debug enabled to make use of Laravel's error handling/reporting.


As I said in the comments, you shouldn't wrap the subdomain in brackets unless you want it to be dynamic.

{blah}.blah means it will capture anything.blah and the route variable $blah will be equal to anything.