I have defined a route like this :
$app->map(['GET', 'POST'],'/abc/[{url}]', function ($request, $response, $args) {
return $response;
})->add(new CustomMiddleware());
Its working fine when I pass a url without http://
but gives me a 404 page not found
-Page with http://
or https://
. I have also tried with url encoded string but gives same error :
http://localhost/slim/public/index.php/abc/http%3A%2F%2Fstackoverflow.com
The requested URL /slim/public/index.php/abc/http://stackoverflow.com was not found on this server.
I am using Slim Version 3.1.
Using an url inside the url
When you adding the url with Slashes then the route do not get execute cause then there is additional path after the url which is not definied inside the route:
E.g.
example.org/abc/test
works fine butexample.org/abc/http://x
will only work with a route definition like this/abc/{url}//{other}
.Using an encoded url inside the url
Apache blocks all request with
%5C
for\
and%2F
for/
in the url with a 404 Not Found error this is because of security reasons. So you do not get a 404 from the slim framework but from your webserver. So you'r code never gets executed.You can enable this by setting
AllowEncodedSlashes On
in you'rhttpd.conf
of apache.My Recommendation to fix this
Add the url as a get parameter there is is valid to have encode slashes without changing the apache config.
Example call
http://localhost/abc?url=http%3A%2F%2Fstackoverflow.com