Deployed Laravel 10 project and it shows index page but when I click e.g. news, about us … it return 404. I check links in inspect and here I have http://ip-address/news, http://ip-address/about-us. How can I fix it? As chatGpt told me for the fix it should change permissions, I try it but doesn’t works
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey!
Besides permissions as GPT suggested, this could be related to a few other things:
Ensure that Apache’s mod_rewrite module is enabled. You can enable it by running the following command:
After enabling, restart Apache to apply the changes:
Laravel uses a .htaccess file in the public directory to rewrite URLs. Ensure the .htaccess file exists and is correctly configured. Here’s the default content for Laravel’s .htaccess file:
Ensure this file is present in your
public
directory.Check your Apache site configuration to allow overrides from the .htaccess file. Edit your site’s configuration file (usually located in
/etc/apache2/sites-available/
) and ensure the<Directory>
directive for your site’s document root (usually thepublic
directory of your Laravel project) looks like this:Replace
/var/www/html/your-laravel-project/public
with the actual path to your project’spublic
directory.After making changes to the Apache configuration or the .htaccess file, restart Apache to apply the changes:
Let me know how it goes! Best,
Bobby