I’ve been working on a Laravel project using a Bootstrap template, and everything works perfectly locally. However, as soon as I deployed my project on a shared server, I encountered a routing issue.
Specifically, when I load the homepage, everything works fine. However, when I click on navbar links to access sections like "About" or "Services," I get a 404 error. Interestingly, when I place the controller for "Services" or "About" in the route of the homepage, the page displays correctly.
Any help would be greatly appreciated
I’ve checked the following:
Controllers and views are in the appropriate directories.
My routes are correctly defined in the web.php file.
I’m using the route() function to generate URLs.
2
Answers
Hello @Herrys Aghista Rachman , I wanted to express my sincere gratitude for your response on Stack Overflow regarding my issue with accessing pages in my Laravel application outside of using
artisan serve
. I followed your advice and tried various approaches, including adding "public" to the routes, modifying the "index.php" file, and creating a "myapp" folder in the root directory of my domain. To provide more context, I have also made modifications to the "index.php" file as follows:I followed these steps meticulously, including creating a "myapp" folder in the domain directory, placing the "index.php" and ".htaccess" files in the root directory of the domain, and modifying the "index.php" file as shown above. However, despite these efforts, the problem persists. The application still only accesses the homepage, and the other routes do not work correctly.
To clarify, when hovering over a button like "Service" or "About," the correct route is displayed. However, upon clicking these links, the application does not navigate to the expected pages.
If you have any further ideas or suggestions to resolve this problem, especially considering the "myapp" folder and index.php modification, I would be grateful for any additional assistance.
Once again, thank you for your invaluable help.
when you run locally, its served and root dir is in public, but if you dont artisan serve it, it need to add root_dir"/public/"your_routes to access it