I am trying to build a one-page dynamic site and I've hit a roadblock. Since URLs like:
index.php?page=Tutorials&Article=0
aren't really all that pretty, I decided to use .htaccess to rewrite URLs, in this case like so:
Tutorials/Articles/0
But that means most of my includes won't work since I use paths relative to the root path of the site:
js/jquery-1.9.1.min.js
I've tried to work around these by using the following code included at the beginning of index.php:
$str = dirname(__FILE__);
$str = str_replace('\\','/',$str);//since i'm using localhost for development, the paths contain backwards slahses so I replace them
$str.='/';
define('ROOT_DIR', $str);
And including everytinhg with php:
echo ROOT_DIR.'js/jquery';
But this aproach doesn't seem to work very well, even though the paths apear to be generated ok:
<script src="C:/xampp/htdocs/Tzeny/js/jquery-1.9.1.min.js"></script>
My question is can you help me find another solution to include my files corectly or to make my solution work?
For first pages it works, so:
Tzeny/Tutorials
works but
Tzeny/Tutorials/Categories/0
doesn't include anything. I used both /Tzeny/ and /. Any more ideas please? Or should I just go back to normal URLs?