Yii Framework Forum: Redirect is not working - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Redirect is not working Rate Topic: -----

#1 User is offline   orkon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 17-May 10

Posted 16 July 2010 - 06:51 AM

Hi, I need redirect user to another site. Here's the code:
public function actionDownload() {
	$model = $this->loadModel();
	if ($model->isValidForGoogle()){
	    $this->redirect($model->fileGoogleLink); //!!! error here
	    Yii::end();
	} else {
	    $file = $model->getFileLocation($model->fileLocalPath);
	    header('Content-type: '.$model->fileMime);
	    header('Content-Disposition: attachment; filename="'.$model->fileDisplayName.'"');
	    header('Expires: 0');
	    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
	    header('Pragma: public');
	    header('Content-Length: ' . filesize($file));
	    ob_clean();
	    flush();
	    readfile($file);
	    Yii::end();
	}
    }


It returns the page:
olor='#eeeeec' align='right'>2464556</td><td bgcolor='#eeeeec'>CInlineFilter->filter(  )</td><td title='/var/www/yii/framework/web/filters/CFilterChain.php' bgcolor='#eeeeec'>../CFilterChain.php<b>:</b>126</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>9</td><td bgcolor='#eeeeec' align='center'>0.1994</td><td bgcolor='#eeeeec' align='right'>2464780</td><td bgcolor='#eeeeec'>CController->filterAccessControl(  )</td><td title='/var/www/yii/framework/web/filters/CInlineFilter.php' bgcolor='#eeeeec'>../CInlineFilter.php<b>:</b>59</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>10</td><td bgcolor='#eeeeec' align='center'>0.2085</td><td bgcolor='#eeeeec' align='right'>2549424</td><td bgcolor='#eeeeec'>CFilter->filter(  )</td><td title='/var/www/yii/framework/web/CController.php' bgcolor='#eeeeec'>../CController.php<b>:</b>999</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>11</td><td bgcolor='#eeeeec' align='center'>0.2379</td><td bgcolor='#eeeeec' align='right'>2789836</td><td bgcolor='#eeeeec'>CFilterChain->run(  )</td><td title='/var/www/yii/framework/web/filters/CFilter.php' bgcolor='#eeeeec'>../CFilter.php<b>:</b>41</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>12</td><td bgcolor='#eeeeec' align='center'>0.2379</td><td bgcolor='#eeeeec' align='right'>2789900</td><td bgcolor='#eeeeec'>CController->runAction(  )</td><td title='/var/www/yii/framework/web/filters/CFilterChain.php' bgcolor='#eeeeec'>../CFilterChain.php<b>:</b>129</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>13</td><td bgcolor='#eeeeec' align='center'>0.2379</td><td bgcolor='#eeeeec' align='right'>2790040</td><td bgcolor='#eeeeec'>CInlineAction->run(  )</td><td title='/var/www/yii/framework/web/CController.php' bgcolor='#eeeeec'>../CController.php<b>:</b>300</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>14</td><td bgcolor='#eeeeec' align='center'>0.2379</td><td bgcolor='#eeeeec' align='right'>2790188</td><td bgcolor='#eeeeec'>FileController->actionDownload(  )</td><td title='/var/www/yii/framework/web/actions/CInlineAction.php' bgcolor='#eeeeec'>../CInlineAction.php<b>:</b>32</td></tr>
</table></font>
HTTP/1.1 302 Found
Date: Fri, 16 Jul 2010 11:47:06 GMT
Server: Apache/2.2.12 (Ubuntu)
X-Powered-By: PHP/5.2.10-2ubuntu6.4
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: http://docs.google.com/a/inf-derby.co.uk/document/edit?id=1I6lQu75yZ1DL7lM2N7qEbd9MbHpMk7OmEfdy0xUqz64&hl=en
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Content-Type: text/html

‹���������������

May the force be with you.
0

#2 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 16 July 2010 - 06:56 AM

You should use:

Yii::app()->end();

0

#3 User is offline   orkon 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 17-May 10

Posted 16 July 2010 - 07:47 AM

View Postandy_s, on 16 July 2010 - 06:56 AM, said:

You should use:

Yii::app()->end();


Thanks a lot! Didn't noticed that call is incorrect....
May the force be with you.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users