I direct all url requests to a front controller. The url requests look something like example.com/controller/action/etc
. The problem is, using relative urls within the program. This works fine if there is only one slash in the url request, but if there is more than one slash, the relative url becomes broken.
At location example.com/controller
, relative url other-controller
works fine taking the user to example.com/other-controller
.
At location example.com/controller/action
, relative url other-controller
doesn't work taking the user to example.com/controller/other-controller
.
Any recommendations on how to get around this? Hoping I can do this without using absolute paths or some url generating code everytime I want to make a url in the app.
In case it matters, I am currently using this .htaccess code to redirect incomming requests to the front controller:
# Point all to index.php except existing files
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>