Emmanuel Mendoza
Emmanuel Mendoza

Reputation: 761

Laravel routes not working correctly on digital ocean LAMP droplet

I am able to access my Laravel site with mysite.com/ routing correctly with / retrieving the welcome view.

I am able to access files in my public directory such as mysite.com/img/test.jpg

But when I try to access any other routes, such as mysite.com/login.

I get the following error

Not Found

The requested URL /contact was not found on this server.

It looks like the application is trying to access another route that is not hitting index.php to generate the view accordingly.

I am using the default .htaccess file that Laravel comes with.

My apache conf file points to my public directory.

Anyone run into a similar issue before?

Upvotes: 0

Views: 2611

Answers (2)

Afraz Ahmad
Afraz Ahmad

Reputation: 5386

I faced same issue and I did everything that was mentioned in different articles but issue was still there

  1. enable rewrite mode using sudo a2ensite rewrite
  2. update conf file located at /etc/apache2/sites-available/example.conf

    <Directory /var/www/html/project/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
  3. then restarted server using sudo service apache2 restart

After doing all above steps issue was still there then I changed apache2.conf file and everything was working fine.

In

/etc/apache2/apache2.conf

change just 3rd line as shown below

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None   //change this line to AllowOverride All
    Require all granted
</Directory>

After that I did not have to add ../index.php/... in the urls

Upvotes: 2

sumit
sumit

Reputation: 15464

May be you need to enable mod rewrite

sudo a2enmod rewrite

Restart Apache.

sudo service apache2 restart

Follow the tutorial on the link below

https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04

Upvotes: 0

Related Questions