After Laravel code development on ec2 machine I faced the following error:
all routes except main “/” give 404 not found
In order to resolve the routes issue we have to perform two steps as I have given below:
Steps
- Enable rewrite_module
- Change the AllowOverride from None to All
Enable rewrite_module
Login to you ec2 machine and modify the following file:
Open terminal and type a2enmod rewrite, It will enable your mod_rewrite module for Apache.
ubuntu@localhost:~$ a2enmod rewrite
Change the AllowOverride from None to All
File Path: /etc/apache2/apache2.conf
ubuntu@localhost:~$ sudo nano /etc/apache2/apache2.conf
Please choose your favorite file editing tool like nano, VI and VIM etc.
Default values given below:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
After editing the directives from None to All
———————————————————–
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
———————————————————–
Now please restart the apache server, like below:
ubuntu@localhost:~$ /etc/init.d/apache2 restart
If you have skills in PHP programming and you want to enhance your career in this field, a PHP certification from StudySection can help you reach your desired goals. Both beginner level and expert level PHP Certification Exams are offered by StudySection along with other programming certification exams.