CodeIgniter Forums
URI with Slash - 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: URI with Slash (/showthread.php?tid=87129)



URI with Slash - Grath - 03-16-2023

I have set the base url set to be 'http://domainname/public/'.  The links to css and js files are <link href="assets/css/..." rel="stylesheet">. Everything works well until I try to access a page with a slash in it, e.g. 'http://domainname/product/1'.  Now the path to the css and js becomes 'http://domainname/product/assets/css/...'.  The css and js files can't be found.
Why does this happen?


RE: URI with Slash - kenjis - 03-16-2023

The current URI: http://domainname/product/1
HTML: <link href="assets/css/..." rel="stylesheet">

"assets/css/..." is a relative path, so it means "http://domainname/product/assets/css/...".


RE: URI with Slash - InsiteFX - 03-16-2023

PHP Code:
<link href="<?= base_url('assets/css/...');?>" rel="stylesheet"