2012-01-25 13 views
5

मुझे ज़ेंड नियंत्रक _redirect विधि का उपयोग करके अनियमित व्यवहार का अनुभव कर रहा है।ज़ेंड _रेडायरेक्ट त्रुटि: बेस यूआरएल दो बार

आवेदन की मेरी प्रति मेरे DocumentRoot में एक सिम्लिंक के माध्यम से उत्पन्न की जाती है। इसके अलावा मेरा डिफ़ॉल्ट रूटर इस पैटर्न पर प्रतिक्रिया के लिए अनुकूलित है: यदि मैं यूआरएल का उपयोग

$url = $this->_helper->url('action', 'controller', $param_A = 'valueA');

:

http://localhost/<appSymLink>/<param_A>/<controller>/<action>/

एक नियंत्रक से, मैं बहुत तरह का URL बना

http://localhost/<appSymLink>/<param_A>/<controller>/<action>/

यह चर निम्न स्ट्रिंग शामिल हैं:

/<appSymLink>/<param_A>/<controller>/<action>/

और जब मैं

$this->_redirect($url);

फोन उपयोगकर्ता स्पष्ट रूप से इस मार्ग, निरर्थक आधार पथ साथ पर भेज दिया जाएगा।

/<appSymLink>/<appSymLink>/<param_A>/<controller>/<action>/

Zend आधार पथ दो बार prepending जा रहा है।

मेरे सहकर्मी की प्रतिलिपि उसकी DocumentRoot में रहती है, और वह इस समस्या का सामना नहीं कर रहा है।

एक खाली आधार पथ परिभाषित कार्रवाई के अंदर, बस ऑपरेशन से पहले, इसलिए तरह काम करता है:

$this->getRequest()->setBaseUrl('');

यह एक व्यवहार्य समाधान स्पष्ट रूप से नहीं है। दूसरी ओर, routeShutdown पर नियंत्रक प्लगइन के भीतर ऐसा करने से एप्लिकेशन निर्देशिका की दोनों घटनाएं समाप्त हो जाती हैं।

क्या किसी को इस समस्या के समाधान के लिए सलाह है, या इसमें चारों ओर देखने के लिए कोई सुझाव है?

उत्तर

6

यदि Url सहायक से उत्पन्न यूआरएल के साथ रीडायरेक्ट करना है, तो आपको रीडायरेक्टर को सूचित करना होगा कि यह पहले से ही यूआरएल के साथ पहले से तय है।

आप निम्नलिखित

return $this->redirect($url, array('prependBase' => false)); 
4

कोशिश का उपयोग करें और सेट prependBase विकल्प FALSE रहे हैं:
$this->_redirect($url, array('prependBase' => FALSE);

Excerpt from ZF reference:

_redirect($url, array $options = array()): redirect to another location. This method takes a URL and an optional set of options. By default, it performs an HTTP 302 redirect.

The options may include one or more of the following:

exit: whether or not to exit immediately. If requested, it will cleanly close any open sessions and perform the redirect.

You may set this option globally within the controller using the setRedirectExit() accessor.

prependBase: whether or not to prepend the base URL registered with the request object to the URL provided.

You may set this option globally within the controller using the setRedirectPrependBase() accessor.

code: what HTTP code to utilize in the redirect. By default, an HTTP 302 is utilized; any code between 301 and 306 may be used.

You may set this option globally within the controller using the setRedirectCode() accessor.

इस does not काम मैं कार्रवाई सहायक 'पुनर्निर्देशक' सुझाव दे सकते हैं यदि आमतौर पर उपयोग किया जाता है:
$this->_helper->getHelper('Redirector')->gotoSimple($action, $controller = null, $module = null, array $params = array())
Action Helper Redirector

संबंधित मुद्दे