简体   繁体   中英

Laravel 5.1 /auth/login not found on Apache + Ubuntu

I am getting exactly the same issue as laravel 5 /auth/login not found . The only difference is that he's using WAMP, and I am using Apache + Ubuntu 14.

When I access http://example.com/index.php/auth/login , the webpage shows perfectly. But http://example.com/auth/login will return this error

The requested URL /auth/login was not found on this server.

I tried both enabling mode_rewrite for Apache, and reinstalled Apache, as suggested in laravel 5 /auth/login not found . Neither way worked.

Make sure you have the correct .htaccess file, say for example you have your installation in /var/www/html/myapp , you should have an .htaccess file inside the public directory ( /var/www/html/myapp/public ) that reads:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /myapp/

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Also, is the Apache document root configured properly?

open up the terminal, run sudo nano /etc/apache2/sites-available/000-default.conf and put these lines int he config file to map the default root to the myapp/public folder :

Alias /myapp /var/www/html/myapp/public/
<Directory "/var/www/html/myapp/public">
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

and then restarts Apache

sudo service apache2 restart

Mod rewrite should be enabled, of course:

a2enmod rewrite
sudo service apache2 restart

You should now be able to access your site at http://localhost/myapp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM