jswoolf01's avatar

Weird error with a Laravel route

Situation: I have a Laravel app with a production version, a staging version, and the development version that I keep on my local hard drive. My dev computer uses XAMPP as its server. Up until a month or so ago, the dev version was in a folder directly under C:, not under xampp/htdocs. I had created a virtual host to redirect "app.test" to the app's root folder, and it all worked fine that way.

Then I reorganized my hard drive, and in the process I moved the dev version to a folder of its own under xampp/htdocs. At the time this didn't seem to make any difference, and it still ran fine. However, while experimenting with a new function today, I discovered that certain routes no longer work. To be exact, any route that gets referenced through an ajax GET call returns a 404 error, even though the route absolutely does exist in web.php, and the code in the web.php file hasn't changed. This problem is limited to my dev version; the routes still work correctly in the staging and production versions. This convinces me that it's a configuration error.

I've checked and confirmed that references to the old virtual host are commented out in the vhosts file. URL rewriting is definitely enabled. The URLs I'm trying to call show up in the routes list. I've shut down and restarted the Xampp server, and even completely rebooted the computer in case something was lingering in RAM. I've checked route definitions, cleared the route cache, checked the syntax of the URLs being called, checked httpd.conf and .htaccess, regenerated the autoload files... everything I can think of. Nothing has helped.

What else could be causing this?

0 likes
7 replies
Glukinho's avatar

As usual, first of all try php artisan optimize:clear and recreate vendor folder (delete it and run composer install)

jswoolf01's avatar

Sorry to report that didn't help, Glukinho. I even threw in a clearing of browser cache, to make sure nothing was lingering there. No joy.

Glukinho's avatar

Do you have the error when serving app with php artisan serve instead of XAMPP?

Use php artisan route:list, do you have all routes there?

jswoolf01's avatar

The routes I'm trying to use are in the routes list. If I run the php artisan server, the route redirects work properly and I do not get the error.

Glukinho's avatar

So the problem is definitely somewhere inside XAMPP settings. Sorry I'm not very familiar with it. Try to revert your latest changes or even reinstall it from scratch. Looking into Apache logs would be useful also.

...Or you may continue using php artisan serve instead of XAMPP web server.

jlrdw's avatar

Dis you tell apache new htdocs location?

DocumentRoot "/xampp/apache/htdocs"
<Directory "/xampp/apache/htdocs">
jswoolf01's avatar

Well, I didn't change the htdocs location - it's still c:/xampp/htdocs, so I'm not sure how that would make a difference. I looked through all the other config files I know about and couldn't find anything that looked wrong, but that may just mean there's a config file I don't know about.

I did manage to fix one of the 'path not found' calls by removing a leading slash from the route in web.php. However, the same fix didn't work with another call that has been generating the 'path not found' error.

Please or to participate in this conversation.