2014-05-12 118 views
1

原諒我這麼頻繁的情況,我搜索了互聯網。我試過了,我什麼都沒有。我無法在Yii中配置路由。如果有人能幫助初學者,我將不勝感激:無法配置路由Yii?

1)我有一個完成的項目Yii。

2)我有云到digitocean,安裝了LAMP,在/ var/www/html上傳的項目中。

3)我/var/www/html/.htaccess

RewriteEngine on 

# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 

4)/var/www/protected/config/main.php

// uncomment the following to enable URLs in path-format 
    'urlManager' => array(
     'urlFormat' => 'path', 
     'rules' => array(
      '<controller:\w+>/<id:\d+>' => '<controller>/view', 
      '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', 
      '<controller:\w+>/<action:\w+>' => '<controller>/<action>', 
     ), 
     //not show index.php 
     'showScriptName' => false, 
    ), 

5)/無功/網絡/html/protected/.htaccess

deny from all 

6)在/ var/www/yii中的Yii框架。

如果您通過瀏覽器輸入項目的URL,請輸入/ var/www/html /,/ var/www/yii /沒有看到,這是正常的嗎? 告訴我如何配置正確的路由? (沒有「/?r =」)。 文件夾777,文件666 rewrite_module(共享)

+0

輸入/ var/www/html /,/ var/www/yii /不會看到什麼意思? –

+0

從瀏覽器輸入URL時,我只得到文件夾/ var/www/html /,例如,如果我輸入有效的http://123.456.2.3/yii/requirements/index.php,那麼我將無法從瀏覽器訪問,只有html文件夾。 –

+0

由於.htacccess設置「拒絕所有」,您的受保護文件夾代碼無法通過瀏覽器訪問。這是Apache的預期設置,應直接訪問受保護的文件夾,但只能通過index.php。 Yii核心庫代碼也是通過瀏覽器無法訪問的。 –

回答

0

嗯,我會建議改變從(http://www.yiiframework.com/wiki/427/htaccess-seo-friendly-url/

RewriteEngine on 
RewriteBase/
# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php) 

# otherwise forward it to index.php 
RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA] 

現在.htaccess文件,如果你沒有設置虛擬主機和應用程序是在某個文件夾像/ var/www/html/MySite。然後將.htaccess中的RewriteBase更改爲RewriteBase /MySite

+0

因爲您有更改,不幸的是,我沒有任何效果。 –