![](/img/trans.png)
[英]Error "Sorry, the page you are looking for could not be found." Laravel 5.5
[英]Sorry, the page you are looking for could not be found. silex error
我的.htaccess:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
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();
訪問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>
文件的位置應該是:
/silex/.htaccess
/silex/web/index.php
這是silex的完整路徑
/var/www/html/silex
“.htaccess”文件
/var/www/html/silex/.htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
“index.php”文件
/var/www/html/silex/web/index.php
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app['debug'] = true;
$app->get('/', function () {
return 'Index Page';
});
$app->get('/hello', function () {
return 'Hello Page';
});
$app->run();
.htaccess應該是
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
VirtualHost文件必須如下所示
<VirtualHost *:80>
ServerName site.com
ServerAlias www.site.com
DocumentRoot /var/www/html/silex/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
而且永恆的作品就像一個魅力! ;-)
“.htaccess”位於/ var / www / html / silex /
和Silex應用程序包
放在/ var / www / html / silex / web /
您可以嘗試添加:
RewriteCond %{REQUEST_FILENAME} !-d.
它對我有用。
這可能有效:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.