【发布时间】:2013-05-30 23:20:00
【问题描述】:
在 Laravel 4 的 /app/ 目录下,有一个名为 server.php 的文件。该文件的内容如下所示:
<?php
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri = urldecode($uri);
$paths = require __DIR__.'/bootstrap/paths.php';
$requested = $paths['public'].$uri;
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' and file_exists($requested))
{
return false;
}
require_once $paths['public'].'/index.php';
这个文件似乎在某种程度上用来模仿 Apache 的 mod_rewrite 功能,但是我在 Laravel documentation 中找不到任何提到它或它的用途的东西。
我目前正在尝试在我不管理的 IIS 服务器上使用 Laravel。我没有能力修改 IIS 上的 URL 重写模块选项(我将来会这样做),但如果可能的话,我想现在就开始使用该框架。这个server.php 文件似乎是一个权宜之计。
任何人都可以阐明server.php 文件的用途以及如果其目的真的是为了模拟Apache 的mod_rewrite 功能,如何使用/激活它?
【问题讨论】: