【问题标题】:Laravel won't route except home directoryLaravel 不会路由除了主目录
【发布时间】:2014-12-18 06:21:26
【问题描述】:

我有一个几乎没有任何变化的全新安装,它不会接受任何新路由。我对虚拟主机文件进行了多种尝试,主要是我在其他网站上找到的,但没有任何效果。

我可以获得默认路由,但没有其他路由。

所以这行得通:

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

但这不是:

Route::get('test', function()
{
    return 'Hello;
});

现在我有一个用于 apache 的 conf 文件,如下所示:

<VirtualHost *:80>

#Host Name
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /path/to/our/public

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /path/to/our/public>
    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
</Directory>

</VirtualHost>

我访问该站点没有问题,它加载并且我从 laravel 获得欢迎页面,但我无法执行任何其他路由或任何操作。权限一切正常,我可以将这条路线更改为任何我想要的。

【问题讨论】:

标签: php laravel routing


【解决方案1】:

我可以通过关注我的问题的 cmets 中的主题来修复错误。

最特别的是.haccess 文件中的this link on the ReWrite engine 属性和this linke 关于更改httpd.conf 文件(我的Apaache/Ubuntu 系统上的apache2.conf)。

【讨论】:

    【解决方案2】:

    我可以通过更改 /var/www in my /etc/apache2/apache2.conf 文件规则上的 AllowOverride 来使其正常工作。

    原文:

    <Directory /var/www/>
      Options Indexes FollowSymLinks
      AllowOverride none
      Require all granted
    </Directory>
    

    新:

    <Directory /var/www/>
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all granted
    </Directory>
    

    【讨论】:

      猜你喜欢
      • 2021-10-01
      • 2015-12-13
      • 2023-04-06
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      • 2015-04-25
      • 2015-05-23
      • 2015-07-07
      相关资源
      最近更新 更多