laravel 5 只有根路由工作
我是拉拉维尔的新手。我使用的是 Ubuntu 15.04。我使用作曲家安装了Laravel Framework版本5.1.7(LTS)和使用命令的灯服务器(我没有安装Homestead)。我正在使用IDE。$ sudo apt-get install lamp-server^
PhpStorm 8.0.3
我创建了三条路线和一个控制器。该文件如下所示:PagesController.php
class PagesController extends Controller
{
public function index()
{
return 'Welcome to my homepage!';
}
public function about()
{
return 'Learn a little about me.';
}
public function hello()
{
return 'Hello World!';
}
}
和看起来像这样:routes.php
Route::get('/', 'PagesController@index');
Route::get('about', 'PagesController@about');
Route::get('hello', 'PagesController@hello');
每当我去(或)它工作时,它都可以正常工作,并向我显示消息。但每当我去或,我得到的是消息。http://localhost:63342/my-first-app/public/
http://localhost:63342/my-first-app/public/index.php
Welcome to my homepage!
http://localhost:63342/my-first-app/public/hello
http://localhost:63342/my-first-app/public/about
404 Not Found
此外,位于 的文件如下所示:.htaccess
my-first-app/public
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# 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]
</IfModule>
我尝试过:
- 我试过,或者它也不起作用。
http://localhost:63342/my-first-app/public/index.php/hello
http://localhost:63342/my-first-app/public/index.php/about
- 我输入了命令,然后是命令,但它也不起作用。
sudo a2enmod rewrite
sudo service apache2 restart
- 我试过了,但它也不起作用。
composer dump-autoload
-
我从 换到 .现在它的一部分看起来像这样:
AllowOverride
None
All
apache2.conf
<Directory /> Options FollowSymLinks AllowOverride All Require all denied </Directory> <Directory /usr/share> AllowOverride All Require all granted </Directory> <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> <Directory /srv/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
但它也不能解决问题。
更新 (7/15/2015):
运行的结果如下所示:php artisan route:list
+--------+----------+-------+------+--------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-------+------+--------------------------------------------+------------+
| | GET|HEAD | / | | App\Http\Controllers\PagesController@index | |
| | GET|HEAD | about | | App\Http\Controllers\PagesController@about | |
| | GET|HEAD | hello | | App\Http\Controllers\PagesController@hello | |
+--------+----------+-------+------+--------------------------------------------+------------+