apache - Silex 位于本地主机 : "Sorry, the page you are looking for could not be found" 上的子目录中

标签 apache .htaccess localhost silex

我知道已经就这个主题提出了几个类似的问题。我已经查看了所有这些,但没有一个能解决我的问题。这是我到目前为止所做的:

  1. 已经考虑使用虚拟主机(出于多种原因,我不想这样做)
  2. 确保 mod_rewrite 已开启(是的,确实如此!)
  3. 编写了一个包含默认值的 .htaccess 文件 Silex 网络服务器配置。发布在[此处](http://silex.sensiolabs.org/doc/web_servers.html)并包含在 silex/目录中。代码如下
  4. 通过 localhost/~username/silex 成功到达 silex/web/index.php 页面(因此 mod_rewrite 肯定有效)。下面还有代码
  5. 我重复了一句“这里!”声明以及 silex/web/index.php
  6. 我尝试了一种解决方案,即在 silex/web/目录中放置第二个 .htaccess 文件

.htaccess 文件:

Options -MultiViews
RewriteEngine On
## this was uncommented because silex is in a subdir
RewriteBase /~username/silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

/silex/web/index.php 文件:

require_once __DIR__.'/../vendor/autoload.php';

$app = new Silex\Application();

echo "HELLO";

$app->get('/', function() {
    return 'Hello!';
});

$app->run();

当我到达 silex/web/index.php 时,我得到的是:

Sorry, the page you are looking for could not be found

我已经为此工作了大约 2 天,但我开始失去它。 任何帮助将不胜感激。 谢谢。

最佳答案

啊哈!我在这里找到了答案 -> MAMP Silex htaccess .

我希望这个解决方案能够帮助其他人摆脱我的痛苦! :)

关于apache - Silex 位于本地主机 : "Sorry, the page you are looking for could not be found" 上的子目录中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21591720/

相关文章:

正则表达式允许除一个之外的所有 php 文件

php - 大量数据出现在服务器而非本地主机中的禁止错误

apache - 构建 minioozie 时出现编译错误

apache - 在 apache 中排除站点重定向到 https

linux - AWS EC2 Linux 托管上的 Apache 和 SFTP 权限

javascript - 当 .htaccess 重定向到 index.php 时,如果文件存在则检查纯 JS

php - 使用 htaccess 传递 URL

java - Lucene OR 搜索使用 boolean 查询

docker - 无法从我的 Docker 容器内部连接到主机的 localhost

ruby-on-rails-3 - 子域约束(Rails 3)使本地服务器(瘦)如此慢