简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM