gaza165 Posted January 23, 2009 Share Posted January 23, 2009 Options +FollowSymLinks RewriteEngine On RewriteBase / ErrorDocument 404 /errors/404page.html RewriteRule ^home index.php RewriteRule ^([_\+A-Za-z0-9]+)?$ index.php?c=$1 RewriteRule ^([_\+A-Za-z0-9]+)/([_\+A-Za-z0-9]+)?$ index.php?c=$1&title=$2 using this .htaccess file the links are knocked out of wack. The css does not get implemented and neither does the images. It seems to be looking in the wrong places for these files. Is there anyway I can set a document root for it all to work from??? Link to comment https://forums.phpfreaks.com/topic/142091-looking-for-files-in-wrong-place/ Share on other sites More sharing options...
gevans Posted January 23, 2009 Share Posted January 23, 2009 I imagine your css file is being called similar to the following; <style type="text/css" media="screen"> /* <![CDATA[ */ @import url(style/default.css); /* ]]> */ </style> The directory and filename are probably different, but you're trying to search from the current directory not from the root url. When you use htaccess rewrite and the url is as follows; ^([_\+A-Za-z0-9]+)/([_\+A-Za-z0-9]+)?$ index.php?c=$1&title=$2 Your web browser believes that your inside a directory deeper than your root so the file to your css file doesn't exist. I'd recommend setting a variable in your configurations file (or something similar) of the websites root, if I were working locally it would be; $root = 'http://localhost/a-project/'; Then add the variable before any file is referenced; <style type="text/css" media="screen"> /* <![CDATA[ */ @import url(<?php echo $root; ?>style/default.css); /* ]]> */ </style> This is the same for images; <img src="<?php echo $root; ?>images/your-pic.jpg" alt="la la" width="10" height="10" /> I hope this explains it for you, Gareth Link to comment https://forums.phpfreaks.com/topic/142091-looking-for-files-in-wrong-place/#findComment-744161 Share on other sites More sharing options...
gaza165 Posted January 23, 2009 Author Share Posted January 23, 2009 Thanks for that... I have done what you suggested and just made a $root variable in my config page and rewrote my link urls etc to include the root. I was thinking of something like that but I thought the problem was with the .htaccess file and therefore it could have been resolved using that. But thankyou very much for the advice, it seems to be working just fine. Link to comment https://forums.phpfreaks.com/topic/142091-looking-for-files-in-wrong-place/#findComment-744163 Share on other sites More sharing options...
gevans Posted January 23, 2009 Share Posted January 23, 2009 In case you're worried that you're missing out on a better solution check out the url of a thread in this forum (you can do it while you're reading right now). Right-Click and hit 'view source'. You'll see that every reference to a file or image has the full url. Now look at the URL in the browser, it's using a htaccess re-write to access everything Link to comment https://forums.phpfreaks.com/topic/142091-looking-for-files-in-wrong-place/#findComment-744167 Share on other sites More sharing options...
gaza165 Posted January 23, 2009 Author Share Posted January 23, 2009 Yeah your right, well it works like a charm. http://www.thedesignmonkeys.co.uk Link to comment https://forums.phpfreaks.com/topic/142091-looking-for-files-in-wrong-place/#findComment-744169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.