简体   繁体   English

重写规则不起作用

[英]Rewrite rule not working

I've done the first steps in Zend Framework with akrabat.com/zend-framework-tutorial/. 我已经使用akrabat.com/zend-framework-tutorial/在Zend Framework中完成了第一步。 The Demo-App works fine, but the CSS. 演示应用程序工作正常,但CSS。 I think my rewrite rules are wrong. 我认为我的重写规则是错误的。 All hrefs looks like: 所有href看起来像:

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

The .htaccess is: .htaccess是:

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. 几乎是ZF随附的产品。 How do you include your stylesheets? 您如何包含样式表? Where do you place them, and where is the index.php etc located? 您将它们放在哪里,index.php等在哪里?

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 . 假设您将应用程序的文档根目录定义为/ htdocs / zf-tutorial / public ,并且样式表位于/ htdocs / zf-tutorial / public / css中 ,那么您必须记住样式包含在/ css /中。 site.css

Also, your hrefs should NOT include index.php, the Apache re-write rules take care of that. 另外,您的href不应包含index.php,Apache的重写规则可以解决这一问题。 Your hrefs should look like: 您的href看起来应该像这样:

  • /index/edit/id/1 / index / edit / id / 1
  • /css/site.css /css/site.css
  • /controller/action/parameterlist /控制器/动作/参数列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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