2014-07-25 52 views
0

我建立了一个laravel4项目,但路线仅适用于路线/。laravel4路线与路线/ /工作,但不适用于其他路线

我还设置了该项目的虚拟主机,虚拟主机指向laravel4 /公共

我在routes.php文件

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

    Route::get('help', function() { 
     return "asdfsafas"; 
    }); 

,当我去/下面的代码,它正确地显示。但如果我去/帮助,它显示在此服务器上找不到请求的URL /帮助。

+0

哦,我忘了添加的index.php :(之后我输入xxxx.dev/index.php/help,它的工作原理,但我如何才能使它工作,如果只输入xxxx.dev /帮助? – Will

+0

你应该工作得很好 - 你用什么作为http服务器,Apache? 尝试与'php artisan serve'在你的laravel根目录。 –

回答

0

看起来你没有启用apache-rewrite模块。很可能它会安装在您的系统上,但未启用。你可以从终端启用它。

sudo a2enmod rewrite

然后重启Apache使用以下命令:

sudo service apache2 restart

这应该可以解决这个问题。

0

设置你的DocumentRoot

laravel4/public/index.php 

,并重新启动Apache。然后你就可以访问路线像

/help 

代替的index.php /帮助