我正在学习苗条的框架.我有一个观点,我必须设置我的网络服务器,以便我可以看到像
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:\wamp64\www\slimapp\public" ServerName slimapp <Directory "C:\wamp64\www\slimapp\public"> AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
127.0.0.1 slimapp
我重新启动了我的服务器但是当我尝试访问我的路由时出现“未找到”错误.
"Not Found The requested URL /hello/uche was not found on this server."
<?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文件移动到根目录
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。