CodeIgniter Forums
url encode - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: url encode (/showthread.php?tid=83465)

Pages: 1 2


RE: url encode - donpwinston - 10-14-2022

(10-02-2022, 11:18 AM)heriniaina Wrote: Just try
PHP Code:
redirect()->to("/operations/path-item/' . $path); 

$path needs to be url encoded or it won't work. But now I think using the '%' as part of the url is not valid. You get a bad request error (400 status code).


https://acme.com/%2Fabc%2F/xyz. is invalid!

Need to use https://acme.com?x=/abc/xyz or better yet https://acme.com?x=%2Fabc%2Fxyz


RE: url encode - donpwinston - 10-19-2022

/ chars in $path will screw it up. They need to be url encoded. But this apparently causes a bad url request. Need to use ?path=xxxxxx.


RE: url encode - ikesela - 10-19-2022

suggestion (using named route):
Code:
$routes->get('/operations/path-item/(:segment)', 'Operations::path_item/$1');

Code:
-route-
$routes->get('/operations/path-item/(:segment)', 'Operations::path_item/$1', ['as' => 'my-route');

-how to use-
return redirect()->route('my-route',[$path]);

- in app-
route_to('my-route',$path);