.htaccess Yii中的Url重写问题

.htaccess Yii中的Url重写问题,.htaccess,mod-rewrite,yii,.htaccess,Mod Rewrite,Yii,我想重写我的yii应用程序URL,我只是不这样做,它在我的本地机器上运行良好。但当我移动到服务器时,它不工作,并显示500个内部服务器错误 我当前的url是这样的 cvdb.example.com/index.php/list/index 我想把它改写成 cvdb.example.com/list/index 下面是我在config/main.php中的代码 'urlManager'=>array( 'urlFormat'=&

我想重写我的yii应用程序URL,我只是不这样做,它在我的本地机器上运行良好。但当我移动到服务器时,它不工作,并显示500个内部服务器错误

我当前的url是这样的

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

我想把它改写成

cvdb.example.com/list/index

下面是我在config/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>',
                                ),
                        ),
这是我在服务器上放置var_dumb$时得到的结果

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) "webmaster@cvdb.example.com"
["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)
}试试这个

<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>

您的应用程序运行时没有在服务器中重写URL吗?请检查您的Apache error.log,看看错误是什么。您好,我这样更改了htaccess,但仍然存在问题500内部服务器错误。那么问题可能是web访问。请检查您是否已将项目放置在正确的目录中,以及是否正在传递正确的URL是的正在运行项目,因为我可以在不使用此htaccess的情况下正确访问该网站。然后尝试使用更新的代码更改该文件,因为它对meHi工作正常。Hi刚才也执行了此操作,但出现了一个错误,如页面未正确重定向。实际上,htaccess和config/main.php在我的本地机器上为我工作,我在那里完成了url重写。
<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>
RewriteBase /