从xampp移动到apache 2.4.7后,Laravel路由返回404.mod_rewrite或htacess或缺少apache设置?

Sen*_*eng 2 apache .htaccess mod-rewrite laravel laravel-routing

一条简单的"测试"路线不断返回404.

Route::get('test', function() {
    return View::make('test');
});
Run Code Online (Sandbox Code Playgroud)

无论是localhost/test还是vhost.dev/test,或者甚至在使用指向特定笔记本电脑的DNS的sub.domain.com/test时,路由都不起作用.

我们使用XAMPP但在得知xampp不适合生产环境后切换到apache.所以我在我们的win7笔记本电脑上安装了apache 2.4.7,php和各种sqlsrv mods.迁移到Apache后,即使使用相同的目录结构,所有路由也都停止工作.

我还尝试将/ public中的所有文件移动到/ htdocs,将应用程序的其余部分移动到根apache2.4文件夹中的laravel文件夹中.

我测试了如果在SO上使用此代码启用了mod_rewrite .这是响应所以我认为它有效吗?

Apache/2.4.7(Win32)PHP/5.4.24

mod_rewrite可用

htaccess的

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

Sen*_*eng 6

这在Laravel论坛上得到了解答.

问题是因为在Apache AllowOverride中设置了None.改变它来All解决所有的路由问题.

以下是帖子中的示例虚拟主机配置:

<VirtualHost *:80>
    ServerAdmin youremail@yahoo.com
    ServerName yoursite.com
    ServerAlias www.yoursite.com
    DocumentRoot "/var/www/yoursite.com/public"
    <Directory /var/www/yoursite.com/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

  • 你有提到论坛帖子的链接吗? (3认同)