Laravel routes do not work except

I spend hours on this problem and hope to find a way out. I configured laravel correctly, created myapp project

My route.php file contains

Route::get('/', function()
{
return View::make('hello');
});

Route::get('/users', function()
{
    return 'Users!';
});

When i started

http://localhost/myapp/public/

I ran laravel start page correctly

When i started

http://localhost/myapp/public/users

I get

The requested URL /myapp/index.php was not found on this server.

I do not know why it is looking for index.php.

When i started

http://localhost/myapp/public/index.php/users

I get a page with the text "Users". I should get this page on startup

http://localhost/myapp/public/users

instead.

Below is my .htaccess

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

    RewriteEngine On
    Rewritebase /myapp/
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

Any ideas? I am running Apache on Linux.

+4
source share
5 answers

Yours is RewriteBaseset to /myapp/, but your index.php file is in /mayapp/public/, right?

, , , RewriteBase /myapp/public/.

+3

application/config/application.php:

'index' => 'index.php',

'index' => '',

laravel index.php .

.htaccess, laravel ( , )

0

:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteBase /my_app
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

, `application/config/app.php ':

'index' => 'index.php'

'index' => ''

0
  • , Apache mod_rewrite.
  • , vhost htaccess.
0

- :

ln -s your/acutal/path/myapp/public app-dev

Now you http://localhost/app-devshould browse perfectly, as well as all the routes. You can change the dev app to whatever you want as a name.

0
source

All Articles