Note that there are some explanatory texts on larger screens.

plurals
  1. POMissing CSS file and images after URL rewrite
    text
    copied!<p>I'm trying to make user friendly URL using mode rewrite. My problem is, that after giving category like 'name' to my URL, when I call the page using new URL, it can't load the CSS file or images.</p> <p>I have a link like:</p> <blockquote> <p>localhost/mywebsite/project?id=22</p> </blockquote> <p>New link is something like</p> <blockquote> <p>localhost/mywebsite/project/22/myproject.project</p> </blockquote> <p>htaccess code:</p> <pre><code>RewriteRule ^project/([0-9]*)/.*\.project$ /project.php?project=$1 [L] </code></pre> <p>(it might not be 100% right but I don't have access to my code right now so I just wrote this and it works fine on the original source)</p> <p>My root directory is localhost/mywebsite/ </p> <p>and my CSS file is in css/style.css</p> <blockquote> <p>localhost/mywebsite/css/style.css</p> </blockquote> <p>my htaccess</p> <blockquote> <p>localhost/mywebsite/.htaccess</p> </blockquote> <p>and my project.php file is in </p> <blockquote> <p>localhost/mywebsite/project.php</p> </blockquote> <p>So in the project page I have access to CSS file by using relative path,</p> <pre><code>&lt;link href="css/style.css" rel="stylesheet" type="text/css" /&gt; </code></pre> <p>but when I use rewritten URL page can't find the CSS file.</p> <p>I can't use absolute path with domain name because I don't have domain yet! and it can be anything.</p> <p>one way is to use relative path to domain as suggested on the similar questions localhost/mywebsite/project.php and when i run my script localy my root directory is localhost so css link should look like</p> <blockquote> <p>href="mywebsite/css/style.css"</p> </blockquote> <p>but when i go live i should change all links to probably something like</p> <blockquote> <p>href="/css/style.css"</p> </blockquote> <p>this seems like lots of work</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload