CodeIgniter Forums
Appache mod_rewrite and CI routing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Appache mod_rewrite and CI routing (/showthread.php?tid=86019)



Appache mod_rewrite and CI routing - ruslan - 01-02-2023

I have this line in my .htaccess file:
Code:
RewriteRule  "^rpc/(.+)"  "/rpc"  [PT]

It redirects all `/rpc/something` requests to `/rpc`
And it really does, but when CI Router processes the request it still uses the full original URL `/rpc/something`

Code:
message: "Can't find a route for 'post: rpc/something'."


This is some $_SERVER vars:
Code:
["REDIRECT_URL"]=>string(4) "/rpc"
["REQUEST_URI"]=>string(12) "/rpc/something"
["PATH_INFO"]=>string(4) "/rpc"
["PATH_TRANSLATED"]=>string(23) "redirect:\index.php\rpc"
["PHP_SELF"]=>string(14) "/index.php/rpc"

May be CI should use REDIRECT_URL instead of REQUEST_URI?


RE: Appache mod_rewrite and CI routing - ozornick - 01-03-2023

See Config/App.php. Replace to PATH_INFO
PHP Code:
public $uriProtocol 'REQUEST_URI'