• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

Resolved Nginx url rewriting not working

capps

New Pleskian
Server operating system version
Alma Linux
Plesk version and microupdate number
Plesk Obsidian 18.0.70
I am trying to get the following rule to work for a domain:
Code:
try_files $uri $uri/ /index.php$is_args$query_string;

When i add that rule in Additional nginx directives only the homepage works. The other pages gives me Plesk 404.

But when I add the same code in /var/www/vhosts/system/domain.com/conf/nginx.conf under /
Code:
location / {
...
try_files $uri $uri/ /index.php$is_args$query_string;
}

Restart nginx, everything works fine.

But I will lose these setting the moment I update the PHP version for example.
So how can I het this to work in Additional nginx directives?
 
Did you wrap the directive rule in a location block too when adding to the Additional nginx directives in Plesk?
 
I tried but then i get the following error

Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/domain.com/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed

I also tried the following
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php$is_args$args last;
}
It works but somehow after some time I get 404 again :/

It does suprises me that I am the only one who uses or has this issue with nginx directives. It there something at fault?
 
I tried but then i get the following error

Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /var/www/vhosts/system/domain.com/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed

Turn off Proxy Mode (on the same settings page), click the Apply button (this is important!) and add the directive rule in a / location block (and click save).
 
Back
Top