2012-11-19 17 views
2

我是新來的Phalcon,我喜歡這個框架,但我有鏈接問題。我使用Phalcon版本0.6.1和XAMPP 1.8.1,它的虛擬主機設置爲xampp/htdocs/test,其中我的phalcon測試是。Phalcon不斷使用index.phtml爲不同的控制器

我一直在關注的教程,來到一個問題。當我使用鏈接加載其他控制器時,地址欄顯示正確的路徑,但據我所見每次都會加載index.phtml。我上傳了文件here,以便您自己看。

如果我使用標籤:: LinkTo(),或因爲它沒有改變不要緊。

編輯:

我跟着instructions,從/測試/測試/公共目錄中刪除的.htaccess文件移動到httpd.conf中。在它的結束,我添加

<Directory "C:/xampp/htdocs/www/test"> 
    RewriteEngine on 
    RewriteRule ^$ public/ [L] 
    RewriteRule (.*) public/$1 [L] 
</Directory> 

<Directory "C:/xampp/htdocs/www/test/public"> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] 
</Directory> 

,並修改了我的httpd-vhosts.conf這樣

ServerAdmin [email protected] 
DocumentRoot "C:/xampp/htdocs/test/public" 
DirectoryIndex index.php 
ServerName example.host 
ServerAlias www.example.host 

<Directory "C:/xampp/htdocs/test/public"> 
    Options All 
    AllowOverride All 
    Allow from all 
</Directory> 

該頁面加載但像/public/css/bootstrap.min.css絕對鏈接不工作,當我點擊鏈接它給了我一個錯誤404,並表示未找到對象。我修改這樣的文件:

<Directory "C:/xampp/htdocs/test"> 
    RewriteEngine on 
    RewriteRule ^$ public/ [L] 
    RewriteRule (.*) public/$1 [L] 
</Directory> 

<Directory "C:/xampp/htdocs/test/public"> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] 
</Directory> 

ServerAdmin [email protected] 
DocumentRoot "C:/xampp/htdocs/test" 
DirectoryIndex index.php 
ServerName example.host 
ServerAlias www.example.host 

<Directory "C:/xampp/htdocs/test"> 
    Options All 
    AllowOverride All 
    Allow from all 
</Directory> 

但是,這使我想到我原來的問題,當我點擊它,即使它說,本地主機index.phtml再次加載鏈接:在URL 8005 /樣品。

回答

2

它看起來像你的Apache配置不允許讀取.htaccess文件:

<VirtualHost *:80> 

    ServerAdmin [email protected] 
    ServerName phalcon.test 

    DocumentRoot /srv/htdocs/sites/test   

    <Directory "/srv/htdocs/sites/test"> 
     AllowOverride All 
     Options All 
     Order allow,deny 
     Allow from all 
    </Directory> 

</VirtualHost> 

此外,在您的公共/ index.php文件檢查$ _GET [ '_ URL']有URI的頂部傳遞給你的瀏覽器

+0

的URI被傳遞到瀏覽器,我修改了虛擬主機,但它並沒有還是一樣的東西保持hapenning。地址欄顯示localhost/sample,但它加載index.phtml而不是sample.phtml。 – Cognis

+0

我在框架文檔中添加了一個章節,解釋如何在虛擬主機中安裝Phalcon應用程序:http://docs.phalconphp.com/zh-CN/0.7.0/reference/apache.html,希望對我有幫助 – twistedxtra

+0

我編輯了在教程中反思問題。不幸的是,我沒有解決我的問題。 – Cognis

相關問題