2013-08-27 70 views
1

我在Zend quick start網址rewritting不是在Zend框架的工作2

我已經下載了程序骨架設置Zend框架2項目按提供的文檔,它顯示「歡迎Zend框架」主頁正確。根據文檔建議,我試圖訪問myproject.localhost/1234網址,但它沒有在項目範圍內顯示404錯誤,但沒有導航欄,CSS(即URL重寫不工作)打開'未找到'頁面。我沒有在我的機器上安裝IIS只有wamp服務器,所以理想它應該工作。

任何人都可以指導我這個錯誤。我創建的虛擬主機也

+0

是否檢查域myproject.localhost點到127.0.0.1:

'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/[:myparam]', 'constraints' => array( 'id' => '\d*', ), 'defaults' => array( 'controller' => 'Application\Controller\Index', 'action' => 'index', ), ), ), 

現在你可以在的IndexController像這樣得到myparam嗎? – michaelbn

回答

0

因爲你想通過請求解析未配置路線 myproject.local/1234左右,如果你想通過1234作爲參數傳遞給你的索引控制器(家庭路線),設置這條路線從this line乞討像如下:

public function indexAction() 
{ 
    $myparam = (int) $this->params()->fromRoute('myparam', 0); 
    var_dump($myparam); // Prints 123 on myproject.localhost/123 and 0 on myproject.localhost 
    exit; // Exit for just simply show the logic. Don't use exit in controller like this. 
}