简体   繁体   中英

Slim framework error apache

My application is not working with Slim Framework and apache.

Route Slim, is not working

$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 in use and index.php(Slim) in same location: public_html/slim/biblioteca/

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

Return error 500 when try access route /teste/

Maybe need config or create httpd.conf and enable .htaccess? also AllowOverride All.

not found this file in /etc/

Can help me?

Printscreen project list files

在此处输入图片说明

add below code in .htaccess file

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]

OR

define root like below example :

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

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

i hope it's work

Use Below code in .htaccess file and it works

<ifModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

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

</ifModule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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