路由器不能在Slim框架上工作
我正在学习苗条框架。我得到了一个点,我必须建立我的网络服务器,我可以看到类似http://slimapp而不是http://localhost/slimapp/public/index.php。路由器不能在Slim框架上工作
我已经包括在我的项目的公用文件夹像这样
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
.htaccess文件我还建立了一个虚拟主机我WAMP的服务器上
<VirtualHost *:80>
DocumentRoot "C:\wamp64\www\slimapp\public"
ServerName slimapp
<Directory "C:\wamp64\www\slimapp\public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我还添加这对我的hosts文件
127.0.0.1 slimapp
我重新启动我的服务器,但我得到一个“Not Found”错误,当我尝试访问我的路线。
"Not Found
The requested URL /hello/uche was not found on this server."
这是我的index.php文件
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '../vendor/autoload.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
请帮我在这里。
尝试将.htaccess文件移动到根目录
你必须提供更多的细节给你的答案。 –
@ muhammad-omer-aslam这个问题已经讨论过 https://*.com/questions/26756768/location-of-htaccess-file – GodlikeRabbit
你应该看看[这里](https://cdnjs.cloudflare.com/ajax /libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap.min.css) –
您运行过'a2enmod rewrite'吗?或者对于Windows - https://webdevdoor.com/php/mod_rewrite-windows-apache-url-rewriting –
仍然无法正常工作 – radioactive
您是如何尝试访问此路线的?通过访问http:// slimapp/hello/uche?如果是的话,你可以尝试访问http:// slimapp /查看你的index.php文件是否被调用? – Nima