Reputation: 2580
I have a Laravel site set up on a Homestead box, so I'm accessing it on sitename.app:8000
. I have a route called "news" but when I try to go to sitename.app:8000/news
I get oddly bounced out to sitename.app/news/
.
If I change the routename to "news2" I can access the desired controller action as per normal at sitename.app:8000/news2
. So somehow it's "news" itself that has become uncooperative - and I'm pretty sure that we aren't even getting as far as the NewsController, when I try to access that url.
Can anyone work out from these symptoms what might be going wrong? One "news"-related change I made at some point was to add $router->model('news', "App\News");
in the boot
method of the RouteServiceProvider, but removing this doesn't seem to make the difference.
ETA: People keep asking for the routes.php file. I can literally remove everything from the file except
Route::get('news', function() {
return "hello world";
});
Route::get('news2', function() {
return "hello world";
});
and /news2 will work but /news will bounce me out. So I remain pretty convinced that the problem is somewhere deeper than routes.php...
Upvotes: 1
Views: 154
Reputation: 2580
I finally worked out what boneheaded action of mine had been causing this behaviour!
I had created a folder in /public named "news"... i.e. with the same name as an important route. Not sure exactly what havoc this was wreaking behind the scenes for Laravel every time a request for /news was being made, but one can assume it was nothing good.
Advice for anyone tearing their hair out over a route that "mysteriously doesn't work" - check your public folder for possible collisions!
Upvotes: 1
Reputation: 495
This is a known issue Larvel missing port
The easiest way to solve this problem is to go to public/index.php
and set the SERVER_PORT
value.
$_SERVER['SERVER_PORT'] = 8000;
Don't forget to set the base url in the config if you are using links on website, the url generator uses the base-url defined in the config.
Last option is to change the vm portfoward in VagrantFile to point to port 80 and use port 80 for your app.
Upvotes: 0