Skip to content

Instantly share code, notes, and snippets.

@pentagonal
Last active June 24, 2016 13:10
Show Gist options
  • Save pentagonal/43ca64b105f26dac6168 to your computer and use it in GitHub Desktop.
Save pentagonal/43ca64b105f26dac6168 to your computer and use it in GitHub Desktop.
Slim 3 Framework to Handle Duplicate Route Request by file access
<?php
/**
* Add MiddleWare to fix URL Rewrites
* Prevent Duplicate Route Access for
* ^/indexfile.php/main === ^/main
* Slim variable is from context object of
* -----------------------------------
* $slim = new \Slim\App();
* -----------------------------
*/
$slim->add(function($request, $response, $next) {
/**
* @var \SLim\Environment
*/
$env = clone $this->environment;
$env['SCRIPT_NAME'] = dirname($env['SCRIPT_NAME']);
$request =
// override request
$this->request =
$requestInterface->withUri(\Slim\Http\Uri::createFromEnvironment($env));
// call next middleware stack to run next progress
return $next($request, $response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment