chibineku Posted September 7, 2009 Share Posted September 7, 2009 I am just fiddling with mod_rewrite in Apache and I've got it working, it's easy enough, but for some reason pages that have been rewritten display without any styles. It's most perplexing. Here is my rewrite rule:RewriteEngine On#Translate products/psorisis/chamomile-skin-cream-P[x] to productview.php5?id=1RewriteRule ^products/.*-P([0-9]+) /productview.php5?id=$1 [L]And here is a sample page:http://www.sinaesthesia.co.uk/products/-P2Anyone got any ideas why? Link to comment Share on other sites More sharing options...
Ingolme Posted September 7, 2009 Share Posted September 7, 2009 It's because it's searching for the stylesheet relative to the URL, and your URL has a lot of extra slashes in it before being rewritten.If you have a link to 'style.css', it will look for www.sinaesthesia.co.uk/products/-P2/style.cssThe best way to solve this is to make all your links relative to the root directory by putting a slash before them:'/style.css' or '/directory/style.css' Link to comment Share on other sites More sharing options...
chibineku Posted September 7, 2009 Author Share Posted September 7, 2009 Ah, okay, that makes sense. Well, actually, no: if I am using mod rewrite to turn the url products/-P1 into products.php5?id=1, say, which is the original URL that I developed with, surely the styles are found relative to that, as they always were? I mean, clearly they aren't, but why? As far as the server is concerned, the URL the user requested is the one I developed with. Link to comment Share on other sites More sharing options...
Ingolme Posted September 7, 2009 Share Posted September 7, 2009 Ah, okay, that makes sense. Well, actually, no: if I am using mod rewrite to turn the url products/-P1 into products.php5?id=1, say, which is the original URL that I developed with, surely the styles are found relative to that, as they always were? I mean, clearly they aren't, but why? As far as the server is concerned, the URL the user requested is the one I developed with.CSS is a client-side technology. You are only rewriting the URL on the server-side, but the client is the one that's making the request, and it's requesting a stylesheet relative to the current location ,which is obtained from the URL. Link to comment Share on other sites More sharing options...
chibineku Posted September 7, 2009 Author Share Posted September 7, 2009 Pantaloons. Muchos gracias. So, I should just add a leading slash to my links/includes? Link to comment Share on other sites More sharing options...
Ingolme Posted September 7, 2009 Share Posted September 7, 2009 Pantaloons. Muchos gracias. So, I should just add a leading slash to my links/includes?A leading slash and the full path to the files, relative to the root directory.Not just for your stylesheets, but all the links and images in the page as well. Link to comment Share on other sites More sharing options...
chibineku Posted September 7, 2009 Author Share Posted September 7, 2009 Not just for your stylesheets, but all the links and images in the page as well.Yep, just discovered that... Link to comment Share on other sites More sharing options...
chibineku Posted September 11, 2009 Author Share Posted September 11, 2009 *this problem resolved* Link to comment Share on other sites More sharing options...
chibineku Posted September 13, 2009 Author Share Posted September 13, 2009 *solved* Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.