Home  >  Article  >  Backend Development  >  初学laravel 遇到的问题

初学laravel 遇到的问题

WBOY
WBOYOriginal
2016-06-06 20:27:401162browse

因为web根目录中有其他的项目,就在根目录中建了一个laravel文件夹用来测试学习,访问http://localhost/laravel/public可以看到欢迎页。后来想去掉public,参考了这个网站http://tutsnare.com/remove-public-from-url-laravel/的第二个方法,直接访问http://localhost/laravel就可以看到欢迎页了。在学习路由的时候,添加了

<code>Route::post('test', function()
{
    return 'test';
});</code>

然后访问http://localhost/laravel/test却一直是404,是哪里的问题呢?

回复内容:

因为web根目录中有其他的项目,就在根目录中建了一个laravel文件夹用来测试学习,访问http://localhost/laravel/public可以看到欢迎页。后来想去掉public,参考了这个网站http://tutsnare.com/remove-public-from-url-laravel/的第二个方法,直接访问http://localhost/laravel就可以看到欢迎页了。在学习路由的时候,添加了

<code>Route::post('test', function()
{
    return 'test';
});</code>

然后访问http://localhost/laravel/test却一直是404,是哪里的问题呢?

第一,首先这是一个post路由,如果是http://localhost/laravel/test访问的话:

<code>Route::get('test', function()
{
    return 'test';
});</code>

第二,请检查你的服务器重(Apache or Nginx)写规则是否符合laravel的规则

第三,为什么不直接用php artisan serve呢

第四:我最近上线的社区,免费视频教程:https://laravist.com/ 有laravel相关的问题可以到这里问我,几乎全天守候。。哈哈哈哈

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn