加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-14 19:41:59 所属栏目:大数据 来源:网络整理
导读:我一直在这个问题上花费数小时,希望找到出路.我已经正确设置了laravel,创建了一个项目myapp 我的route.php文件只包含 Route::get('/',function(){return View::make('hello');});Route::get('/users',function(){ return 'Users!';}); 我跑的时候 http://loc
我一直在这个问题上花费数小时,希望找到出路.我已经正确设置了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 /.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读