繁体   English   中英

Slim框架错误Apache

[英]Slim framework error apache

我的应用程序不适用于Slim Framework和apache。

Slim路线,不起作用

$app->group("/teste", function() {
    $this->get("/", function(Request $request, Response $response, $args = []) {
        return $response->write("deu");
    });

    $this->get("/:nome", function(Request $request, Response $response, $args = []) {
        return $response->write("deu ".$args['nome']);
    });
});

使用的.htaccess文件和index.php(Slim)在同一位置:public_html / slim / biblioteca /

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

尝试访问路由/ teste /时返回错误500

也许需要配置或创建httpd.conf并启用.htaccess? 还允许全部覆盖。

在/ etc /中找不到此文件

可以帮我?

打印屏幕项目列表文件

在此处输入图片说明

在.htaccess文件中添加以下代码

RewriteEngine On

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with,content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

要么

定义根,如下例所示:

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

$app->post('/example', 'examplefunction');

我希望它能工作

在.htaccess文件中使用下面的代码,它可以工作

<ifModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]

</ifModule>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM