dbo Posted April 2, 2008 Share Posted April 2, 2008 So I've built a little framework, that uses MVC and mod_rewrite to create friendly urls. I've used the URL segment approach, pretty similar to how CI does it. I've just launched the first official site on this new framework... naturally I'm still working through some logistics on how things should be handled, etc. I've just noticed something weird. For example: http://www.derekbobo.com/Testbed/services This displays the services page as expected. Now if you enter: http://www.derekbobo.com/Testbed/index.php/services which should technically do the same thing, it loads in the content and everything correctly, but none of the images/stylesheets work. I would think that things should still be relative to index.php but apparently not. Admittedly I'm new to mod_rewrite... is it something funky with that where it's assuming it's in the services directory (that doesn't exist) or something else? Any ideas? Quote Link to comment Share on other sites More sharing options...
dbo Posted April 2, 2008 Author Share Posted April 2, 2008 Update: Apparently the problem exists anytime it goes beyond one segment above the root. So for example: http://www.derekbobo.com/Testbed/services/1 Generates an error page b/c the services controller doesn't have a 1 method. But the error page should still inherit the page layout, but again the images/stylesheets aren't loaded. Quote Link to comment Share on other sites More sharing options...
dbo Posted April 2, 2008 Author Share Posted April 2, 2008 It appears I was right about apache thinking it was in a different directory. So I've got 2 problems now: The original system was using this for my .htaccess ErrorDocument 404 /Testbed/index.php While this works... apparently using the 404 to handle the requests is bad. And then the obvious problem is that it doesn't handle paths right when additional values are passed. I tried using the example that was provided with CI... but it doesn't work either. RewriteEngine on RewriteCond $1 !^(index\.php) RewriteRule ^(.*)$ /Testbed/index.php/$1 [L] Quote Link to comment Share on other sites More sharing options...
dbo Posted April 2, 2008 Author Share Posted April 2, 2008 I believe I've got a rewrite rule correctly written now, but none of the pages show any of the stylesheets or images now. I'm sure that using absolute paths would fix this... but I've gotta imagine there is a better way than requiring absolute paths in my views. This really screws with portability. I know this isn't a problem unique to me... show me some love and help a brother out. Quote Link to comment Share on other sites More sharing options...
dbo Posted April 2, 2008 Author Share Posted April 2, 2008 Hell, using an absolute path to the stylesheet didn't even work. I'm pretty much completely clueless. Here's the absolute path to the stylesheet: /Testbed/Media/CSS/styles.css and that didn't even work.... Quote Link to comment Share on other sites More sharing options...
dbo Posted April 2, 2008 Author Share Posted April 2, 2008 Latest update: I've got a rewrite rule working, so I'm not relying on ErrorDocument anymore. In the normal case, things are working again.. that's the good news. Problem is if I take it up another level: http://www.derekbobo.com/Testbed/services/1 Breaks the layout again, because the server thinks its in a different directory. However, absolute paths will work (that's good, I guess). So the question now remains... how can I structure a rewrite rule so that the paths to images/stylesheets, etc is not broken, without having to use absolute paths? Quote Link to comment 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.