【发布时间】:2012-01-04 00:58:23
【问题描述】:
我决定证明silex框架。我将 index.php 文件、.htaccess 和库 silex.phar 放在我称为“prova”的同一目录中。
但是当我在浏览器中访问 url “localhost/~username/prova”时,我收到错误 403 Access Forbidden。
我的错误是什么?
在我在我的应用中使用的代码下方。
index.php 文件
<?php
require_once __DIR__.'/silex.phar';
$app = new Silex\Application();
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
$app->run();
还有.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /path/to/app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [QSA,L]
</IfModule>
【问题讨论】:
-
index.php的完整路径是什么?在机器上,而不是通过浏览器。
-
我的 index.php 的完整路径是
/Users/username/Sites/prova -
检查您的 apache 错误日志。通常在
/var/log/apache2/error.log. -
日志文件的输出:
Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/username/Sites/prova/ -
@reb2awrl 请写下您的解决方案作为答案,并作为正确的接受。