我决定证明silex框架。我将index.php文件,.htaccess和库silex.phar放在我称为“prova”的同一目录中。
但是当我在浏览器中访问网址“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>
答案 0 :(得分:2)
如果你的应用程序在/ ~username / prova中运行,那么我怀疑你需要设置:
RewriteBase /~username/prova/
答案 1 :(得分:1)
有点晚了,但是在我的测试环境中删除了index.php之前的斜杠。 这会在.htaccess中留下以下代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>