ober Posted March 4, 2010 Share Posted March 4, 2010 So here is my structure: public_html /site -> production site /v2 -> testing site I've added a .htaccess file to the v2 directory to play with rewriting the urls. I want www.test.com/v2/models/ab/75 to be the URL and for it to actually display www.test.com/v2/index.php?req=prod&cat=ab&model=75 I'm using the following rule in the .htaccess file at the v2 level: RewriteRule ^models/([a-z]+)/([0-9]+)$ v2/index.php?req=prod&cat=$1&model=$2 [NC,L] It works, and loads the page, and the URL stays as I would like, but all of my CSS/JS/ and images do not load because they all use relative paths. Any ideas how I can get around that? Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/ Share on other sites More sharing options...
Zane Posted March 4, 2010 Share Posted March 4, 2010 what do your paths look like... the "relative" ones.. Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021643 Share on other sites More sharing options...
salathe Posted March 4, 2010 Share Posted March 4, 2010 To put it bluntly, don't use relative paths. (I could explain at length that that is the solution, with pretty examples and such but it wouldn't really say anything other than that.) Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021645 Share on other sites More sharing options...
steviewdr Posted March 4, 2010 Share Posted March 4, 2010 Hey Ober, Long time no see Anyways, something like this *might* work: RewriteCond %{REQUEST_FILENAME} !^.*\.css$ RewriteCond %{REQUEST_FILENAME} !^.*\.jpg$ I pulled it from a htaccess, so apologies if it doesn't work, but it might give you an idea. -steve Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021648 Share on other sites More sharing options...
ober Posted March 4, 2010 Author Share Posted March 4, 2010 <link rel="stylesheet" href="style/DefaultNew.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="style/Print.css" type="text/css" media="print"> <link rel="stylesheet" href="style/CSS.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="style/search.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="style/home.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="style/200803.css" type="text/css" media="screen, projection, print"> <link rel="stylesheet" href="style/200811.css" type="text/css" media="screen, projection, print"> <script type="text/javascript" src="libs/jquery-1.js"></script> <script type="text/javascript" src="libs/Default.js"></script> <script type="text/javascript" src="libs/swfobject.js"></script> <script type="text/javascript" src="libs/__utm.js"></script><script language="JavaScript1.5">_ujv='1.5';</script> <script type="text/javascript" src="libs/redesign.js"></script> Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021652 Share on other sites More sharing options...
ober Posted March 4, 2010 Author Share Posted March 4, 2010 To put it bluntly, don't use relative paths. (I could explain at length that that is the solution, with pretty examples and such but it wouldn't really say anything other than that.) So then I have to change every path in every file when I move everything to the final (production) location? No thanks. I'd rather deal with the 'less than pretty' URLs. Hey Ober, Long time no see Anyways, something like this *might* work: RewriteCond %{REQUEST_FILENAME} !^.*\.css$ RewriteCond %{REQUEST_FILENAME} !^.*\.jpg$ I pulled it from a htaccess, so apologies if it doesn't work, but it might give you an idea. -steve Good to see you too Steve. Yeah, been too busy to hit this place up lately. I'll give that a whirl. Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021653 Share on other sites More sharing options...
ober Posted March 4, 2010 Author Share Posted March 4, 2010 No dice, steve. Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021655 Share on other sites More sharing options...
ober Posted March 4, 2010 Author Share Posted March 4, 2010 To put it bluntly, don't use relative paths. (I could explain at length that that is the solution, with pretty examples and such but it wouldn't really say anything other than that.) Thinking about this further, I guess I could use PHP to dynamically build the absolute path. Just seems like a hassle. Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021658 Share on other sites More sharing options...
steviewdr Posted March 4, 2010 Share Posted March 4, 2010 How about: RewriteCond %{REQUEST_URI} !^.*\.css.*$ [NC] Afraid I don't know enough of mod_rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021662 Share on other sites More sharing options...
cags Posted March 4, 2010 Share Posted March 4, 2010 I believe the problem is not that the .css file path itself is being redirected, it's rather that when the page that's been redirected attempts to fetch the a file, it tries relative to it's REQUEST_URL, not relative to it's actual position. Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021664 Share on other sites More sharing options...
ober Posted March 4, 2010 Author Share Posted March 4, 2010 Yeah, that's what I'm gathering from some further googling. I guess I'm going to throw in absolute paths. SUCK. Quote Link to comment https://forums.phpfreaks.com/topic/194177-rewrite-causing-ignore-of-cssjs/#findComment-1021665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.