由于apache2配置,Laravel 4控制器路由无法正常工作

Gav*_*ers 3 php apache apache2 laravel laravel-4

我正试图在家里的本地服务器上设置laravel,我似乎无法获得控制器路由,例如:

Route::controller('home','home');
Run Code Online (Sandbox Code Playgroud)

这段代码可以在我工作的服务器上运行,并且我已经阅读了几个论坛,这个论坛声称问题是因为apache2没有配置为查看.htaccess文件.

我已经搞砸了一段时间,但我似乎仍无法得到任何工作.我进入/ etc/apache2/sites-available并创建了我自己的配置文件,名为site1,如下所示:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/laravel/
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/laravel/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
Run Code Online (Sandbox Code Playgroud)

然后我运行a2dissite默认&& a2ensite site1和/etc/init.d/apache2重启但没有任何反应.

感谢您的帮助,如果我需要澄清任何内容,请告诉我.

原来apache甚至没有读取.htaccess文件.我故意在其中写了一些废话本应该导致错误但事实并非如此.

Gav*_*ers 5

问题原来是mod_rewrite.c没有启用,所以我运行了a2enmod重写,一切都开始工作了.我注意到laravel中的.htaccess文件依赖于它.傻我.谢谢你的帮助.