EL MASLOUHI HAMZA
EL MASLOUHI HAMZA

Reputation: 63

All other routes aren't working except '/' on my Laravel project

I'm a trying to learn the framework Laravel. I installed it and I configured the virtual hosts

When I tried to access the project, it works

but when I tried another root such as /justForTest it didn't work I don't know why ?!

Route::get('/', function () {
   return view('welcome');
});

Route::get('/justForTest', function () {
   //return view('welcome');
   return "Hello world !";
});

image

I tried many solutions on the net in vain. I use kubunto 17.04 and this is what I did

-I added the Directory with AllowOverride all on my lsapp.div.conf

<VirtualHost *:80>

ServerAdmin [email protected]
ServerName lsapp.dev
ServerAlias www.lsapp.dev
DocumentRoot /var/www/html/lsapp/public
     <Directory "/var/www/html/lsapp/public">
     AllowOverride all
     </Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

-I have enabled the rewrite mode with a2enmod rewrite

-I added the line RewriteBase /laravel/ on my htaccess file

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

    RewriteEngine On
    RewriteBase /laravel/   
    # 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]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Thank's for helping me.

Upvotes: 1

Views: 97

Answers (1)

Ruchita Sheth
Ruchita Sheth

Reputation: 860

Remove or comment #RewriteBase /laravel/ in your .htacess

Upvotes: 1

Related Questions