I’m having a problem with relative paths in CodeIgniter. I was following a tutorial and doing everything as instructed, but I encountered errors when using relative paths in forms, links, and images (e.g., in the action attribute of forms, href attributes for links, and src attributes for images).
To be specific, when I try to include assets like CSS files or images, the paths don’t seem to resolve correctly.
Here are a few examples of what I’m experiencing:
1.
<img src="assets/images/avatar2.jpg" alt="Avatar">
—>The image doesn’t load, and I get a 404 error for the image file.
2.
<a href="/blog">Blog</a> <a href="/blog/post">Post</a>
Clicking these links results in a 404 error.
In an attempt to resolve this, I switched to another tutorial, but encountered the same issue. For example, in the new tutorial, the instructor created a folder public/assets/css and included a bootstrap.min.css file. He then called it in the view page using base_url(), and it worked for him but not for me.
Despite ensuring there are no spelling mistakes and verifying the files exist in the correct locations, the paths still don’t work for me. It seems like this might be an issue specific to CodeIgniter’s configuration or how paths are resolved within the framework.