简体   繁体   中英

Nginx Rewrite Rule with PHP not working properly

I have an url structure like this:

And want to rewrite it to:

To do so I tried around 1000 combinations which all come basically down to this code:

location /overview/ {
    rewrite ^/overview/(.+)$ /triggers/overview.php?technician=$1 last;
}

I'm using Ajenti, php-fpm 7 & nginx.

Any Ideas?

Also here the whole .conf-File for context:

server {
    listen *:80;
    listen *:443 ssl;
    ssl_certificate /certificates/fullchain.pem;
    ssl_certificate_key /certificates/privkey.pem;


    server_name subdomain.domain.com;

    access_log /var/log/nginx/technicians.access.log;
    error_log /var/log/nginx/technicians.error.log;

    root /srv/technicians;
    index index.html index.htm index.php;

    # ACME challenge for letsencrypt
    location ^~ /.well-known/acme-challenge {
        alias /var/www/letsencrypt.sh;
    }

    # rewrite overview
    rewrite_log on;

    location /overview/ {
        rewrite ^/overview/(.+)$ /triggers/overview.php?technician=$1 last;
    }


    # rewrite urls of requirements
    rewrite ^/requirements/(.*)$ /requirements/$1.html last;


    location ~ [^/]\.php(/|$) {

        fastcgi_index index.php;
        include fcgi.conf;
        fastcgi_pass unix:/var/run/ajenti-v-php7.0-fcgi-technicians-php7.0-fcgi-0.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

}

I found the solution myself: The configuration was correct, all I had to do is make sure that nginx is really restarting.

In Ajenti this didn't work through the UI so i tried it through nginx -s reload , which worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM