Last active
June 24, 2016 13:10
-
-
Save pentagonal/43ca64b105f26dac6168 to your computer and use it in GitHub Desktop.
Slim 3 Framework to Handle Duplicate Route Request by file access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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