A pretty URL for a specific PHP page?

Jore community at thoughtmaybe.com
Mon Sep 6 04:58:37 UTC 2021


Hi there,

Is it possible to make a pretty URL for a specific PHP page?

I'd like https://domain.com/report/ to render
https://domain.com/index.php?r=app%2Fform&id=2lyEsw

So I tried this location block, but I get 403 forbidden:

    location /report {
        index index.php?r=app%2Fform&id=2lyEsw;
        alias /var/www/easyforms;
    }



Here's my whole config:


server {
    listen       443 ssl http2;
    server_name  report.DOMAIN.COM;
    root /var/www/easyforms;
    gzip on;
    ssl_certificate /var/lib/acmesh/report.DOMAIN.COM/fullchain.cer;
    ssl_certificate_key
/var/lib/acmesh/report.DOMAIN.COM/report.DOMAIN.COM.key;
    ssl_protocols TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers
'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES12$
    ssl_session_cache shared:SSL:5m;
    ssl_session_timeout 10m;

    location /report {
        index index.php?r=app%2Fform&id=2lyEsw;
        alias /var/www/easyforms;
    }

    location / {
        index index.php index.html;
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi.conf;
        fastcgi_intercept_errors on;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 300s;
    }
}


What am I doing wrong?

Thanks!
Jore



More information about the nginx mailing list