Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的网站上设置了一个语言切换器,但现在我只知道如何重定向到主页:
public function englishAction(Request $request) { $this->get('session')->setLocale('en_US'); return $this->redirect($this->generateUrl('homepage')); }
如何重定向到当前页面?
尝试:
return $this->redirect($request->headers->get('referer'));
或另一种解决方案:您可以将 url 链接作为 get 参数放回,并在“englishAction”操作中将其用于重定向。