Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nam_co's avatar

Avoid landing page redirects in forge

Hi, Im getting a recommendation to Avoid landing page redirects, right now my domain should be https://www.mydomain.com but when I type my domain.com in gmatrix Im getting this recommendation

Avoid landing page redirects for the following chain of redirected URLs.

http://mydomain.com/ redirects to https://mydomain.com/

https://mydomain.com/ redirects to https://www.mydomain.com/

is it possible to avoid the non 'www' redirect and go straight to https://www this is what forge automatically puts in:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.mydomain.com;
    root /home/forge/www.mydomain.com/public;

Appreciate any help, thanks

0 likes
1 reply
Robstar's avatar

Quickest method - add both versions of the site in forge i.e. www.site.com and site.com.

In the Nginx config for the none www. version use the following config:

server {
    server_name example.com;
    return 301 $scheme://www.example.com$request_uri;
}

Your config will be something along the lines of:

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/www.mydomain.com/before/*;

server {
    listen 80;
    server_name www.mydomain.com;
    return 301 $scheme://www.mydomain.com$request_uri;
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/www.mydomain.com/after/*;

Please or to participate in this conversation.