@@ -64,7 +64,7 @@ public function redirectAction($route, $permanent = false)
64
64
*
65
65
* @return Response A Response instance
66
66
*/
67
- public function urlRedirectAction ($ path , $ permanent = false , $ scheme = null , $ httpPort = 80 , $ httpsPort = 443 )
67
+ public function urlRedirectAction ($ path , $ permanent = false , $ scheme = null , $ httpPort = null , $ httpsPort = null )
68
68
{
69
69
if (!$ path ) {
70
70
return new Response (null , 410 );
@@ -88,10 +88,28 @@ public function urlRedirectAction($path, $permanent = false, $scheme = null, $ht
88
88
}
89
89
90
90
$ port = '' ;
91
- if ('http ' === $ scheme && 80 != $ httpPort ) {
92
- $ port = ': ' .$ httpPort ;
93
- } elseif ('https ' === $ scheme && 443 != $ httpsPort ) {
94
- $ port = ': ' .$ httpsPort ;
91
+ if ('http ' === $ scheme ) {
92
+ if ($ httpPort == null ) {
93
+ if ('http ' === $ request ->getScheme ()) {
94
+ $ httpPort = $ request ->getPort ();
95
+ } else {
96
+ $ httpPort = $ this ->container ->getParameter ('request_listener.http_port ' );
97
+ }
98
+ }
99
+ if ($ httpPort != null && $ httpPort != 80 ) {
100
+ $ port = ": $ httpPort " ;
101
+ }
102
+ } else if ('https ' === $ scheme ) {
103
+ if ($ httpsPort == null ) {
104
+ if ('https ' === $ request ->getScheme ()) {
105
+ $ httpsPort = $ request ->getPort ();
106
+ } else {
107
+ $ httpsPort = $ this ->container ->getParameter ('request_listener.https_port ' );
108
+ }
109
+ }
110
+ if ($ httpsPort != null && $ httpsPort != 443 ) {
111
+ $ port = ": $ httpsPort " ;
112
+ }
95
113
}
96
114
97
115
$ url = $ scheme .':// ' .$ request ->getHost ().$ port .$ request ->getBaseUrl ().$ path .$ qs ;
0 commit comments