2014-01-14 75 views
0

我想重寫我的yii應用程序的網址,我只是做了它,它在我的本地機器中正常工作。但是當我移動到它不能正常工作的服務器,並顯示一個500內部服務器錯誤在Yii的網址重寫問題

我當前的URL是這樣的

cvdb.example.com/index.php/list/index

我想重寫它作爲

cvdb.example.com/list/index

這是我在配置/ main.php

'urlManager'=>array(
           'urlFormat'=>'path', 
           'showScriptName'=>false, 
           'caseSensitive'=>false, 
           'rules'=>array(
             '<controller:\w+>/<id:\d+>'=>'<controller>/view', 
             '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
             '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 
           ), 
         ), 
代碼10

這裏是我的.htaccess代碼

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA] 

這裏我所得到的,當我把var_dumb($ _ SERVER)

array(39) { 
["DOCUMENT_ROOT"]=> 
string(29) "/home/bridge/public_html/cvdb" 
["GATEWAY_INTERFACE"]=> 
string(7) "CGI/1.1" 
["HTTP_ACCEPT"]=> 
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" 
["HTTP_ACCEPT_LANGUAGE"]=> 
string(14) "en-US,en;q=0.5" 
["HTTP_CONNECTION"]=> 
string(5) "close" 
["HTTP_COOKIE"]=> 
string(339) "fbm_1=base_domain=.cvdb.example.com; PHPSESSID=a6b697793d5abf01012435cf868a2f13; 52862fa7c29cebef614e5f38c01514c2=5571bdfdfdfdfdfdfb1ed61d4cae29f6145035a37a9d4ee45e83a%3A4%3A%7Bi%3A0%3Bs%3A1%3A%221%22%3Bi%3A1%3Bs%3A13%3A%22Administrator%22%3Bi%3A2%3Bi%3A31536000%3Bi%3A3%3Ba%3A1%3A%7Bs%3A4%3A%22role%22%3Bs%3A2%3A%2210%22%3B%7D%7D" 
["HTTP_HOST"]=> 
string(23) "cvdb.example.com" 
["HTTP_USER_AGENT"]=> 
string(72) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0" 
["HTTP_X_FORWARDED_FOR"]=> 
string(14) "220.336.5.3" 
["HTTP_X_FORWARDED_HOST"]=> 
string(23) "cvdb.example.com" 
["HTTP_X_FORWARDED_SERVER"]=> 
string(23) "cvdb.example.com" 
["HTTP_X_REAL_IP"]=> 
string(14) "220.336.5.3" 
["PATH"]=> 
string(13) "/bin:/usr/bin" 
["PHPRC"]=> 
string(13) "/home/bridge/" 
["QUERY_STRING"]=> 
string(0) "" 
["REDIRECT_PHPRC"]=> 
string(13) "/home/bridge/" 
["REDIRECT_STATUS"]=> 
string(3) "200" 
["REDIRECT_UNIQUE_ID"]=> 
string(24) "UtTWkTIfkzwAAddfdFUWCbwAAAAD" 
["REDIRECT_URL"]=> 
string(11) "/list/index" 
["REMOTE_ADDR"]=> 
string(14) "220.227.90.185" 
["REMOTE_PORT"]=> 
string(5) "43681" 
["REQUEST_METHOD"]=> 
string(3) "GET" 
["REQUEST_URI"]=> 
string(11) "/list/index" 
["SCRIPT_FILENAME"]=> 
string(39) "/home/bridge/public_html/cvdb/index.php" 
["SCRIPT_NAME"]=> 
string(10) "/index.php" 
["SERVER_ADDR"]=> 
string(12) "50.31.147.60" 
["SERVER_ADMIN"]=> 
string(33) "[email protected]" 
["SERVER_NAME"]=> 
string(23) "cvdb.example.com" 
["SERVER_PORT"]=> 
string(2) "80" 
["SERVER_PROTOCOL"]=> 
string(8) "HTTP/1.0" 
["SERVER_SIGNATURE"]=> 
string(0) "" 
["SERVER_SOFTWARE"]=> 
string(156) "Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8e-fips-rhel5 DAV/2   mod_python/3.3.1 Python/2.4.3 mod_jk/1.2.37 mod_bwlimited/1.4 mod_perl/2.0.6 Perl/v5.8.8" 
["UNIQUE_ID"]=> 
string(24) "UtTWkTIfkzwAAFUWCbwAAAAD" 
["ORIG_PATH_INFO"]=> 
string(11) "/list/index" 
["ORIG_PATH_TRANSLATED"]=> 
string(39) "/home/bridge/public_html/cvdb/index.php" 
["PHP_SELF"]=> 
string(10) "/index.php" 
["REQUEST_TIME"]=> 
int(1389680273) 
["argv"]=> 
array(0) { 
} 
["argc"]=> 
int(0) 

}

+0

您的應用程序是否在不重寫服務器的URL的情況下運行? –

+0

檢查你的Apache error.log,看看錯誤是什麼。 – anubhava

回答

0

試試這個

<ifModule mod_rewrite.c> 
# Turn on the engine: 
RewriteEngine on 
# Don't perform redirects for files and directories that exist: 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# For everything else, redirect to index.php: 
RewriteRule . index.php 
</ifModule> 

或者試着簡單地從你的.htaccess文件中刪除這行代碼

RewriteBase/
+0

嗨,我改變了這樣的htaccess,但仍然有問題500內部服務器錯誤。 – Sanjay

+0

然後問題可能是與網絡access.check您是否已將項目放在正確的目錄中,並且您傳遞正確的URL –

+0

是的,它正在工作的項目,因爲我可以正確訪問該網站與此htaccess。 – Sanjay