apache - Modrewrite Makes Scripts/CSS not appear due to their path location -
i'm having issues modrewrite rule i'm applying.
it works intended, when viewing page, it's expecting absolute path scripts/css/images. won't display unless go through each 1 individually , prepend "../" them (i.e. 'icons/book.gif' => '../icons/book.gif')
is there way fix modrewrite itself? here rule i'm applying:
<ifmodule mod_rewrite.c> rewriteengine on rewriterule ^category/([a-za-z\+]+)/?$ fact.php?category=$1 </ifmodule>
edit: function determine absolute path, recommended use links on site.
// determines , returns absolute url path function absolute_url ($page = "index.php") { $url = "http://" . $_server['http_host'] . dirname($_server['php_self']); // remove trailing slashes $url = rtrim($url, '/\\'); // add page $url .= "/" . $page; return $url; }
have rules this:
options +followsymlinks -multiviews rewriteengine on rewritecond %{request_filename} !-f rewriterule ^category/([a-za-z\+]+)/?$ fact.php?category=$1 [l,nc]
this avoid rewriting files present (static files css, js, images).
alternatively can use html base tag static files:
<base href="http://www.example.com/static/" />
however recommended use absolute path static files.
Comments
Post a Comment