js file is loading but css file is not loading

In my index.html file js file is loading but css file is not, after debugging in access_log file i found that server sends css file with 200 response but my html file is not loading that, i redirected all requests to index.php on my server using .htaccess file, i tried to get css file directly with url and it is working fine, i am working in localhost environment, i have main htdocs folder it contains all file index.php and index.html and also contains assets folder in that my js and css files are placed.
html file:

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link media="all" rel="stylesheet" href="/assets/test.css" type="text/css" />
  <div class="top_bar">
    <h1 id="status"></h1>
  <div id="test" class="wrapper">
  <div class="bottom_bar">
    <form class="text" onsubmit="onEnter(); return false" autocomplete="off">
      <input type="text" name="text" placeholder="Type here" id="text" />
    <button id="send">
  <script src="assets/chat.js"></script>

My index.php file:


$raw_url = $_SERVER['REQUEST_URI'];

$url = explode('?', $raw_url);

$route = $url[0];

$query = $url[1];

if (substr($route, 0, 8) == '/assets/') {
  $file_name = substr($route, 8);
  if(file_exists('assets/' . $file_name)) {
    readfile('assets/' . $file_name);
  else {
} else {
  switch ($route) {
    case '/':

.htaccess file:

RewriteEngine on
RewriteRule (.*) index.php
RewriteRule ^assets/ - [L,NC]

81 thoughts on “js file is loading but css file is not loading”

Leave a Comment