Jump to content

PHP Help/Framework/Design type question...


dbo

Recommended Posts

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?

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.