用wamp打开index.php时找不到页面

时间:2018-07-12 20:24:12

标签: php apache routes wamp

我正在尝试用php创建一个api,但是当尝试访问任何端点时,浏览器会告诉我:

  

找不到您要查找的页面。检查地址栏   以确保您的网址拼写正确。如果其他所有方法都失败了,您可以   请访问下面的链接访问我们的主页。

当我尝试打开index.php时,也会发生同样的事情。唯一正确加载我的页面是默认情况下wamp的本地主机,我已经验证了所有虚拟主机的创建,认为这可能是问题所在,但仍然无法正常工作。

我已经使用了苗条的框架和wamp工具本身来创建虚拟主机

archivo httpd-vhosts.conf:

<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerName site
    DocumentRoot "c:/wamp64/www/slim1/public"
    <Directory  "c:/wamp64/www/slim1/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>



<VirtualHost *:80>
    ServerName apiexample
    DocumentRoot "c:/wamp64/www/apiexample/public"
    <Directory  "c:/wamp64/www/apiexample/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

archivo主机:

127.0.0.1 localhost
127.0.0.1 site

::1 localhost
::1 site

127.0.0.1   apiexample
::1 apiexample

index.php:

<?php

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';
require '../src/config/db.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
    $name = $args['name'];
    $response->getBody()->write("Hello, $name");

    return $response;
});


require "../src/routes/usuarios.php";
$app->run();

?>

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

<IfModule mod_rewrite.c>
  Header add Access-Control-Allow-Origin: "http://localhost:4200/"
  Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
  Header add Access-Control-Allow-Headers: "Content-Type"
  RewriteEngine on
  RewriteBase /
</IfModule>

0 个答案:

没有答案