php - Url rewriting broke link to css -


I am using the following setting to retype the URL:

  rewrite Engine rewrite %% REQUEST_FILENAME}! -d Recovery code% {REQUEST_FILENAME}! -f rewriting rule ^ (. *) $ Index.php? Url = $ 1 [QSA, L]   

in index.php is parsed $ _ GET ['url'] In Examples:

  root / user / id / 1 / name / bobby // is the user page, id = 1, name = Bobby root / blog / post / 123 / title / welcome // The first one is the name of the page, the following parameter is the name of the page / key, "I now have the styling sheet when I come to  root /  Browse the links of those which are inserted inside the HTML of the page and the page is shown correctly. I browse  root / index  (which is similar to  root / ), this page displays (with content and other content) correctly, but the link (Even the html structure is written correctly) the stylesheet is not loaded  

How can I fix it?

Edit

/ P>

The path to the CSS file is as follows:

  project / view / Css / common.css   

file containing this

  is in project / public / index.php //. Regenerate another rule with Htaccess   

This brings me to a link index.php) such as

  ../view / Css / common.css   

but it works differently according to URL. URL = public / index / project / public / view / css / url = for general css = example for public / project / view / css / general css // good #:

  # url = Public / index / key / value / public / index / key / view / css / normal css // broken    

I think that you have two problems (as the answer Given that, your problem has not been resolved yet ...):

  1. You are rewriting all the filenames, when the browser css / index .css , then your rewrite is index.php? Url = css / index.css . Answer to @Colley2 must be resolved.

  2. You are not using full path for your CSS files. The server is translating the requested page like / user / id / 1 / name / bobby to /index.php?etc .... , but when the browser The css file that contains something like css / index.css in your code, is actually /user/id/1/name/bobby/css/index.css and the file is not present. You can solve it by using the complete path on your external files (CSS, JS, image etc.) such as /css/index.css .

    Edit: Depending on your comments, both of your paths are relative and your CSS is not available by the browser, so you need it

  3. For CSS Project / Public directory (like project / public / css )
  4. Like your CSS Use css / index full path css .
  5. Make sure that the URLs of your external files are not written again by the server.

Comments