ローカルホストに Zend Framework (バージョン 1.12) をインストールしましたが、IndexController からのアクションへのアクセスに問題がありますが、同じコード、同じアクション名は、他のコントローラー (TestController など) で完全に正常に動作します。
class IndexController extends Zend_Controller_Action {
public function init(){/* Initialize action controller here */}
public function indexAction(){//some code}
public function addAction(){//some code}
public function otherAction(){//other code}
}
class TestController extends Zend_Controller_Action {
public function init(){/* Initialize action controller here */}
public function indexAction(){//some code}
public function addAction(){//some code}
public function otherAction(){//other code}
}
アドレス バー zf.local/ を入力すると、index/index.phtml ファイルからコンテンツを受け取りますが、zf.local/index/index ZF と入力すると、URL が見つからないことがわかります。zf.local/test/index と入力すると、すべて正常に動作します アドレスバーに zf.local/index/add と入力すると、404 エラーが返されますが、zf.local/test/add と入力すると、すべて正常に動作します。
仮想ホストを AllowOverride All に設定し、Apache からの書き換えモジュールを有効にしました。Apache を停止、再起動、リロードし、PC を再起動しました。Apache や仮想ホストに問題はないと思うので、これを書いています。 . 私のApacheと仮想ホストの構成
zf.local/default/index/add と入力しようとすると、コードが機能するため、アドレスバーの /index の前に /default を配置する必要があります
これは、/index の前に /default の URL に挿入する Zend ヘルパーで解決できると思います 。Zend Framework の公式ドキュメントですが、その方法がわかりません。今まではバグしか取れなかった
index.html から、次のコードでコントローラーからアクションを呼び出します。
<a href="<?php echo $this->url(array('controller' => 'index',
'action' => 'add'));
?>">Add</a>