我的.htaccess:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
index.php文件:
<?php
ini_set('display_errors', 1);
require_once __DIR__.'../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
$app->run();
Run Code Online (Sandbox Code Playgroud)
访问localhost/silex/hello/world时出现此错误:
"抱歉,找不到您要查找的页面."
为什么?
在你的试试这个.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [QSA,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
文件的位置应该是:
/silex/.htaccess
/silex/web/index.php
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19263 次 |
| 最近记录: |