SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ZendFramework and mod_rewrite question

    Ok so I've been looking over the zend framework code, mainly in its controller portion. I am wondering if there are any advantages/disadvantages to the way the zend framework router works. It seems like it only requires one mod_rewrite rule to pass all requests to the bootstrap file since the router actually disects the request. Verses having a bunch of mod_rewrite rules that would convert the controller,action, and parameters into a query string and the application would just grab them like normal $_GET values and use them as needed.

    Basically it would be using $_SERVER['REQUEST_URI'] (zend framework) to get the controller, action, and params , vs. a bunch of mod_rewrite rules for the different controller combinations and using $_GET. Is one method better than the other, or have more pros out weight its cons?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i havent looked at the zend controller portion, but it sounds like what i usually do if the majority of my urls need to be rewritten, i just rewrite everything to php and let my script figure it out by parsing the request uri.

    i do however have rules in my htaccess to allow some files to just be served by the webserver instead of being rewritten to php. but i usually just have some directorys where i turn off mod rewrite and put static files like images/css/js etc... in those directorys.

    ive found it to be a rather clean and easy to manage solution. im curious what others think as well though.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya, I think it may be more effecient to let the script handle formatting the request than mod_rewrite. Esspecilly if there would end up being a lot of rules which I think there would be. Because wouldn't you need a new rule each time the format of the URI changed? Like if you had an article which was /articles/200/ which rewrote to articles.php?id=200. Then wouldnt you also need a new rule to match for /articles/edit/200/ which rewrote to articles.php?a=edit&id=200. So it would seem that you would end up with a lot of mod_rewrite rules and if one of the pages is at the bottom of the list it may take more time than it should when compared with having the script handle all that. I know doing it using a script would be more flexible than the mod_rewrite way, but I didn't know if there was some advantages to using a bunch of rewrite rules compared to a script handling it.

    Anyone else want to share how they do it?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •