view not found

Published 1 month ago by danielesposito

Hello to everyone, I really need help.

I have a laravel project and I moved the whole project from my local machine to a virtual machine and now I'm struggling with several problems. If I log into my virtual machine and try to access via browser with localhost my site runs ok. But if a try on a different computer on the same LAN to access the site I can see only the welcome page, the other one doesn't work, it shows me, sorry, page not found. I even tried to create other views from scratch on VM and getting the same error.

I will really appreciate any suggestions from you guys. I really need to resolve!

Thanks to you all.

ChristophHarms

By default, you can not access your VM from outside the host with most virtualisation providers. You'll have to explicitly configure it to be accessible from outside. How this configuration is done depends on the virtualisation provider you use.

A quick google search for "virtualbox access vm outside host" brings up multiple solutions. Just replace "virtualbox" in the search query with the provider you use and follow any instructions, you should be fine. :)

danielesposito

@ChristophHarms Hello,

As you said in the post I cannot access to the VM from the outside world, but as I said in the post I can access to the welcome view. So if it is like you mentioned I couldn't access even to the welcome view isn't it ? Anyway I will check it out ! Thanks for reply.

D

Snapey
Snapey
1 month ago (683,015 XP)

Did you copy .htaccess to your VM

Do you have rewrite enabled in your VM?

Is public folder your document root?

ChristophHarms

as I said in the post I can access to the welcome view

Oh, must have skipped over that, sorry.

What do you have in your .env under "APP_URL"? This is used by laravel to create links etc. By default it's set to http://localhost, so all the (relative) URLs will be written as http://localhost/{{relative url}}.

If you are accessing the site from outside the host, that doesn't work. If, from your other machine, you access your site via http://192.168.10.100 (for example), then that's what should be in your .env file as "APP_URL", or all Laravel-generated links will point to localhost, which, of course, won't work.

danielesposito

@Snapey hello,

Yes I did it all! But still not working.

danielesposito

@ChristophHarms

And after that I should run php artisan clean:cache and other command ?? I will try and I will let you know.

Thanks

ChristophHarms

And after that I should run php artisan clean:cache and other command ??

You got me there. Caching has always been a stepchild to me. I don't really know when exactly Laravel caches what exactly for which exact reasons.

But whenever I write something new and it does not work for no obvious reasons, I religiously clear all available caches and try again. ;)

danielesposito

@ChristophHarms,

I have tried what you said, with no success. I changed the "APP_URL" under .env file but still not working. You how can I check the generated URL of the app?

Those are the step I did:

  1. composer install
  2. php artisan migrate
  3. php artisan cache:clean
  4. npm install
36864
36864
1 month ago (26,430 XP)

As you said in the post I cannot access to the VM from the outside world, but as I said in the post I can access to the welcome view.

Are you still running a server on your host machine? You might just be getting the welcome view from a completely unrelated project.

If you've eliminated that possibility, and are sure you're actually connecting to your VM's web server, and you've correctly set up your vhosts and public folders in the VM's web server, try clearing your view cache (php artisan view:clear), route cache (php artisan route:clear) and config cache (php artisan config:clear)

Heck while you're at it, clear your compiled classes too (php artisan clear-compiled)

And if none of that helps, see what happens if you just remove the root route from your web.php file. (and clear the route cache if you have it)

danielesposito

@36864 Hello there,

Yes, I'm sure that my server is running and it's well configured as I got another project there with vue and is everything fine.

I just wrote all the command you suggesting but still get not working.

I removed the root route from web.php and when I tried to access it by typing from the other pc ( no from the VM ) I got the same issue, "sorry, page not found", then added again and getting back just the route.

This is struggling me because I can't really understand why if I try from local is working.

Thanks anyway

D

ChristophHarms

how can I check the generated URL of the app?

# cwd must be your project's root
[email protected]$ php artisan tinker

# wait for Psy Shell to start, then

>>> url('/some/relative/url'); # or route() or asset() ... just some url helper
# => "http://your.configured.app.url/sone/relative/url"
36864
36864
1 month ago (26,430 XP)

I'm running out of ideas for what could be causing this.

How have you been trying to navigate to other pages? Links from the homepage?

Can you try directly accessing a known route through the address bar?

Do you have any wildcard routes that could be trying to load things that don't exist? As in Route::get('/{field}', '[email protected]');?

Do you have debugbar installed to see if your routes are being hit at all?

danielesposito

@36864

The other routes I have created are protected by the make: auth command. What I have done is that I created a new route and a new view called home and still not working. I did a fresh installation of laravel and everything worked even from outside. I tried to change the port of my server to:82 and still not working. But now like a magic when I came back to the initial setting, everything working fine, but I can't you guys explain how. How can I activate debugbar? maybe can be helpful next time.

Really thanks for the help!

36864
36864
1 month ago (26,430 XP)

If the routes were protected by auth, the likely scenario is that you were having session store issues.

https://github.com/barryvdh/laravel-debugbar

Please sign in or create an account to participate in this conversation.