[NOTE] - This issue was found to be due to incorrect Apache configuration. I have posted an answer which explains what I did wrong. I hope this helps!
I'm starting a project with Laravel and I've begun with creating the general routes. I want to create a request structure so that URLs of example.com
go to organic routes, admin.example.com
go to the admin dashboard of my app, and {workspace}.example.com
goes to a dynamic route for my users' personal workspaces.
Currently I have the following routing structure:
Route::group(array('domain' => 'admin.example.com'), function() {
Route::get('/', function() {
echo 'This route works fine';
});
Route::get('/test', function() {
// This route doesn't work...
echo 'Test';
});
});
Route::group(array('domain' => '{workspace}.example.com'), function() {
Route::get('/', function() {
echo 'This route works fine';
});
Route::get('/test', function() {
// This route doesn't work...
echo 'Test';
});
});
Route::group(array('domain' => 'example.com'), function() {
Route::get('/', function() {
echo 'This route works fine';
});
Route::get('/test', function() {
// This route doesn't work...
echo 'Test';
});
});
As you see, I have three routing groups. The first is for the admin prefixed URLs (to ensure that admin.example.com
is not mistaken for a workspace prefix). There is the workspace prefix, and then finally the no-prefix route group.
As indicated in the code, all Route::get('/', ...
routes work fine, however anything that is not the root does not work. I am receiving 404 errors when trying to go to example.com/test
(and all the other domain prefixes).
What can I do to my routing to fix this and get the routes Route::get('/test', ...
to work rather than just the /
routes?
Much appreciated!
Route::get('/')
andRoute::get('/test')
, does the/test
route work? I have a sneaking suspicion this has nothing to do with groups/subdomains and everything to do with your webserver/.htaccess
config. – ceejayozAllowOverride
toAll
in the apache conf. Thanks for pointing this out! – Ryan