使用内置的PHP 5.4服务器提供Drupal 7

Jas*_*sta 13 php webserver drupal drupal-7

我期待使用PHP的内置服务器开发Drupal 7站点.我已成功运行Drupal而没有干净的url(例如index.php?q =/about /)但是干净的url(例如/ about /)通常依赖于mod_rewrite或它的等价物.在文档中,我看到你可以运行带有路由器文件的PHP服务器,如下所示:

php -S localhost:8000 routing.php
Run Code Online (Sandbox Code Playgroud)

我应该在routing.php中放置什么来模拟mod_rewrite?

gho*_*oti 7

该任务基本上是用PHP为您的router.php文件编码Drupal的.htaccess .

这是一个开始:

<?php

if (preg_match("/\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)/", $_SERVER["REQUEST_URI"])) {
  print "Error\n"; // File type is not allowed
} else
if (preg_match("/(^|\/)\./", $_SERVER["REQUEST_URI"])) {
  return false; // Serve the request as-is
} else
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) {
  return false;
} else {
  // Feed everything else to Drupal via the "q" GET variable.
  $_GET["q"]=$_SERVER["REQUEST_URI"];
  include("index.php");
}
Run Code Online (Sandbox Code Playgroud)

这应该被视为alpha质量.它表示通过Drupal 7.14的.htaccess文件步行3分钟,跳过需要超过10秒钟思考的任何内容.:)

但是,它允许我启动Drupal的安装脚本,样式表,JS和图像按预期加载,并使用Clean URL命中Drupal的页面.请注意,要在此环境中安装 Drupal,我需要一个可能不会成为Drupal 7一部分的补丁.