skip to Main Content

I have a running nginx web server using PHP 7.4 (FPM) using Ubuntu 20.04. The web server runs on port 2080 and 2443, and they are port forwarded on port 2443 LAN 443 WAN.

I have a PHP script that should redirect me to another page of my website, but it redirects me on a page that uses port 2443 which is inaccesible since i need 443. I tried all possible things but it won’t work and it will still redirect me to port 2443.
Note that i cannot use port 443 locally on my nginx server, so that isn’t a option.

I have tried:

header('Location: https://domain.tld:443/page');
header('Location: https://domain.tld/page');
header('Location: https://domain.tld./page');

however with no success as it’s redirecting me on https://domain.tld:2443/page .

So how do i fix this?

2

Answers


  1. Chosen as BEST ANSWER

    Fixed. The problem was that it redirected to "page/".

    I changed this: header('Location: https://domain.tld/page');

    to this: header('Location: https://domain.tld/page/');

    And now it does no longer redirect to a :2443 port.


  2. If you use a relative url

    header('Location: ./page'); // assuming your cwd is in the root
    

    the server will take care of protocol (HTTP vs HTTPS) and port (it will reuse the one used for the request).

    this URL also is relative to your site and retains protocol and port used in the request.

    header('Location: /page');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search