Saturday, February 5, 2011

Rewrite rule not working

I've done the first steps in Zend Framework with akrabat.com/zend-framework-tutorial/. The Demo-App works fine, but the CSS. I think my rewrite rules are wrong. All hrefs looks like:

  • /~cm/zf-tutorial/public/index.php/index/edit/id/1
  • /~cm/zf-tutorial/public/index.php/css/site.css

The .htaccess is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteBase /
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php

Can someone give me a hint how to change it?

  • I think the rewrite rule looks fine. It's pretty much the one that ships with ZF. How do you include your stylesheets? Where do you place them, and where is the index.php etc located?

    Say you define your document root for the application as /htdocs/zf-tutorial/public, and that you have your stylesheets in /htdocs/zf-tutorial/public/css, then you have to remember that styles are included as /css/site.css.

    Also, your hrefs should NOT include index.php, the Apache re-write rules take care of that. Your hrefs should look like:

    • /index/edit/id/1
    • /css/site.css
    • /controller/action/parameterlist

0 comments:

Post a Comment