这是我的代码:
/**
* @Route("/redirect", name="redirect")
* @return RedirectResponse
*/
public function show()
{
return $this->redirect('https://www.google.com/');
}
我想要的是使用上述方法将人们重定向到外部网址。
documentation说要像我一样在控制器$this->redirect
中使用。
在我的开发环境中,它可以工作,但是在我的服务器上,这种重定向不起作用。此代码转到 https://www.myhostname.com/
在两个环境中,PHP 7.3.6
和nginx 1.15.3
具有相同的php.ini
。两种环境都在Windows Server 2016上
我真的不明白为什么我的代码在我的产品服务器上不起作用。有人知道吗?
谢谢
编辑:
这是https://myHostName.com/redirect
PS C:\windows\system32> curl -v https://myHostName.com/redirect
VERBOSE: GET https://myHostName.com/redirect with 0-byte payload
VERBOSE: received 5669-byte response of content type text/html; charset=UTF-8
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="icon" type="/image/png" href="/Images/favicon.png">
<title>MyHostName</title>
<meta name="author" content=...
RawContent : HTTP/1.1 200 OK
X-Robots-Tag: noindex
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Cache-Control: max-age=0, must-revalidate, private
Content-Type: text/html; charset=UT...
Forms : {}
Headers : {[X-Robots-Tag, noindex], [Strict-Transport-Security, max-age=31536000; includeSubDomains;
preload], [Cache-Control, max-age=0, must-revalidate, private], [Content-Type, text/html;
charset=UTF-8]...}
Images : {@{innerHTML=; innerText=; outerHTML=<IMG class="logo-myHostName col-12" alt=logo_myHostName
src="/Images/logo_myHostName.png">; outerText=; tagName=IMG; class=logo-myHostName col-12;
alt=logo_myHostName; src=/Images/logo_myHostName.png}}
InputFields : {@{innerHTML=; innerText=; outerHTML=<INPUT type=hidden
value=CgCMIXd_Lv3NVSIALzV4xvibTvCbLhyqZYpHDwQy0qg name=token>; outerText=; tagName=INPUT;
type=hidden; value=CgCMIXd_Lv3NVSIALzV4xvibTvCbLhyqZYpHDwQy0qg; name=token}, @{innerHTML=;
innerText=; outerHTML=<INPUT id=userName class=form-control name=_username placeholder="User
Name">; outerText=; tagName=INPUT; id=userName; class=form-control; name=_username;
placeholder=User Name}, @{innerHTML=; innerText=; outerHTML=<INPUT id=password class=form-control
type=password value="" name=_password placeholder="Password">; outerText=; tagName=INPUT;
id=password; class=form-control; type=password; value=; name=_password; placeholder=Password}}
Links : {@{innerHTML=<IMG class="logo-myHostName col-12" alt=logo_myHostName
src="/Images/logo_myHostName.png"> ; innerText= ; outerHTML=<A class="navbar-brand "
href="/myHostName"><IMG class="logo-myHostName col-12" alt=logo_myHostName
src="/Images/logo_myHostName.png"> </A>; outerText= ; tagName=A; class=navbar-brand ;
href=/myHostName}, @{innerHTML=Login; innerText=Login; outerHTML=<A class=nav-link
href="/login">Login</A>; outerText=Login; tagName=A; class=nav-link; href=/login},
@{innerHTML=Register; innerText=Register; outerHTML=<A href="/register">Register</A>;
outerText=Register; tagName=A; href=/register}, @{innerHTML=Contact US; innerText=Contact US;
outerHTML=<A href="#">Contact US</A>; outerText=Contact US; tagName=A; href=#}...}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 5669
编辑2 :
正确的$this->redirect
返回一个RedirectResponse
,但这没什么改变:)
编辑3 : 这是我的防火墙规则:
access_control:
- { path: /company/support, roles: [ROLE_BLOCKED, ROLE_USER, ROLE_ADMIN] }
- { path: /company, role: ROLE_USER }
- { path: ^/admin, role: ROLE_ADMIN }