【问题标题】:Apache redirect is failing for LaravelLaravel 的 Apache 重定向失败
【发布时间】:2013-09-07 02:15:49
【问题描述】:

我在 Apache2 上启用了 mod_rewrite,在默认文件中启用了 AllowOverride All。但是,当从 Laravel 给定 pretty url 时,Apache(重新启动后)似乎仍然无法重定向。

WORKS(返回:用户!)localhost/laratest/public/index.php/users

不起作用 (404)localhost/laratest/public/users

我的 .htaccess:(我也尝试了Documentation 中建议的方法,但无济于事)

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

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

Laravel routes.php:

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

Route::get('users', function()
{
    return 'Users!';
});

我在 Ubuntu 中使用默认的 LAMP 堆栈和配置。任何想法为什么这不起作用?

【问题讨论】:

标签: apache .htaccess mod-rewrite laravel


【解决方案1】:

按照 laravel 网站 (http://laravel.com/docs/installation#pretty-urls) 的建议,试试这个:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

【讨论】:

  • 谢谢,但我也试过这个也无济于事,我会把它添加到问题中。
【解决方案2】:

您是否将RewriteBase 设置为/laratest/public

Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /laratest/public
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

【讨论】:

    猜你喜欢
    • 2014-12-06
    • 2016-04-03
    • 2017-02-09
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    • 2016-01-12
    • 1970-01-01
    • 2015-01-26
    相关资源
    最近更新 更多