2014-10-05 114 views
0

我在我的ubuntu服务器上有apache2。laravel虚拟主机404错误

还有就是我/etc/apache2/sites-available/laravel.conf

<VirtualHost *:80> 
    ServerName http://laravel.mysite.com/ 
    DocumentRoot "/var/www/laravel/public" 
    <Directory "/var/www/laravel/public"> 
     AllowOverride all 
     Order allow,deny 
      Allow from all 
    </Directory> 
</VirtualHost> 

,我必须打开Apache的mod_rewrite功能。

还有就是我/var/www/laravel/app/routes.php

<?php 
Route::get('/', function() 
{ 
    return View::make('home/index'); 
}); 
Route::get('/hehe', function() 
{ 
    return "hehe'; 
}); 

还有就是我/var/www/laravel/public/.htaccess

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 

    # Redirect Trailing Slashes... 
    RewriteRule ^(.*)/$ /$1 [L,R=301] 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule> 

现在,我可以访问http://laravel.mysite.com,但是当我访问http://laravel.mysite.com/hehe时,它会给出404错误。有什么我配置错了吗?

回答

0

我唯一要做的就是设计的apache2.conf,补充一点:

<Directory /var/www/laravel/public> 
    Options FollowSymLinks 
    AllowOverride All 
</Directory>