php – 没有在Slim框架上工作的路由
发布时间:2020-12-13 22:28:06 所属栏目:PHP教程 来源:网络整理
导读:我正在学习苗条的框架.我有一个观点,我必须设置我的网络服务器,以便我可以看到像 http://slimapp而不是 http://localhost/slimapp/public/index.php. 我已经在我的项目的公共文件夹中包含了一个.htaccess文件 RewriteEngine onRewriteCond %{REQUEST_FILENAM
我正在学习苗条的框架.我有一个观点,我必须设置我的网络服务器,以便我可以看到像
http://slimapp而不是
http://localhost/slimapp/public/index.php.
我已经在我的项目的公共文件夹中包含了一个.htaccess文件 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . index.php [L] 我还在我的wamp服务器上设置了一个虚拟主机 <VirtualHost *:80> DocumentRoot "C:wamp64wwwslimapppublic" ServerName slimapp <Directory "C:wamp64wwwslimapppublic"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> 我还将此添加到我的hosts文件中 127.0.0.1 slimapp 我重新启动了我的服务器但是当我尝试访问我的路由时出现“未找到”错误. "Not Found The requested URL /hello/uche was not found on this server." 这是我的index.php文件 <?php use PsrHttpMessageServerRequestInterface as Request; use PsrHttpMessageResponseInterface as Response; require '../vendor/autoload.php'; $app = new SlimApp; $app->get('/hello/{name}',function (Request $request,Response $response) { $name = $request->getAttribute('name'); $response->getBody()->write("Hello,$name"); return $response; }); $app->run(); 请帮帮我. 解决方法
尝试将.htaccess文件移动到根目录
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |