title: How can I load css or js file in codeigniter 4?
body: <p>When I am trying to load css or javascript file then it returns 404 error.</p>
  
  <p>I've tried to use helpers such as HTML helper's link_tag, URL helper's base_url methods, it will make a route to the file, but not loadable.</p>
  
  <p>This is my Controller:</p>
  
  <pre class="lang-php prettyprint-override"><code>class Pages extends Controller{
  
      public function viewPage($page)
      {
          if(!is_file(APPPATH."/views/pages/$page.php")){
              throw new \CodeIgniter\Exceptions\PageNotFoundException($page);
          }
  
          helper('html');
  
          $data['title'] = $page == 'noticeboard' ? "page1" : "page2";
  
          if($page != "index"){
              echo view('templates/header', $data);
          }
  
          echo view("pages/$page", $data);
  
          if($page != "index"){
              echo view("templates/footer", $data);
          }
      }
  
  }
  </code></pre>
  
  <p>My Router:</p>
  
  <pre class="lang-php prettyprint-override"><code>$routes-&gt;get("/", "Pages::viewPage/index");
  </code></pre>
  
  <p>Header in HTML:</p>
  
  <pre><code>&lt;?=link_tag('public/css/style.css')?&gt;
  </code></pre>
  
  <p>The assets folder is located in the very root of htdocs(I'm using xampp apache server).</p>
  
  <p>And when I try to load CSS or JS, I get this error:</p>
  
  <p><a href="https://i.stack.imgur.com/OPUyj.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OPUyj.png" alt="error message"></a></p>
  
  <p>I'm completely new to CodeIgniter, so any bits of help would be appreciated.</p>
  
  <ul>
  <li>Directory structure:<br></li>
  </ul>
  
  <pre>
  htdocs
    -public
      --CSS
       ---style.css
      --JS
       ---app.js
    -app
      --controllers
        ---Page.php
      --views
        ---pages
          ----index.php
  </pre>
  
  <p><strong>* I've changed my CSS, JS file routes from assets to public *</strong></p>