php – 除了root之外,Laravel路由不起作用

前端之家收集整理的这篇文章主要介绍了php – 除了root之外,Laravel路由不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在这个问题上花费数小时,希望找到出路.我已经正确设置了laravel,创建了一个项目myapp

我的route.PHP文件只包含

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

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

我跑的时候

http://localhost/myapp/public/

我正确地得到了laravel启动页面

我跑的时候

http://localhost/myapp/public/users

我明白了

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

我不知道为什么它在寻找index.PHP.

我跑的时候

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

我得到一个文本“用户”的页面.我应该在运行时获取页面

http://localhost/myapp/public/users

代替.

下面是我的.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>

有任何想法吗?我在Linux上运行Apache.

解决方法

您的RewriteBase设置为/ myapp /但您的index.PHP文件位于/ mayapp / public /不是吗?

因此,我认为你会发现RewriteBase需要是/ myapp / public /.

猜你在找的Laravel相关文章