• We value your experience with Plesk during 2026
    Please help us understand which Plesk features made your work easier this year, what is still missing and how AI should help you in Plesk ?
    Take this short 5-minutes survey. Your answers go straight into the Plesk roadmap for 2027.

Nginx Rewrite issue

Søren

New Pleskian
TITLE:
Nginx Rewrite issue​
PRODUCT, VERSION, OPERATING SYSTEM, ARCHITECTURE:
Plesk Onyx​
PROBLEM DESCRIPTION:
I was trying to use my typical rewrights for prestashop, but somehow there is an issue setting it.

Some of the vars are removed from the string and that makes it fail.

rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

It removes $1 and $2​
STEPS TO REPRODUCE:
Try and enter

rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

To the nginx config area.​
ACTUAL RESULT:
Removes needed vars​
EXPECTED RESULT:
Expected result is it saves rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

Since it works with nginx.​
ANY ADDITIONAL INFORMATION:
​
YOUR EXPECTATIONS FROM PLESK SERVICE TEAM:
Help with sorting out​
 
Hello @Søren .

I have just tried to add the rewrite directive in nginx additional directives and I haven't notice this issue.
And why do you not use the directive try_files instead of rewrite ? (I do not find your configuration exemple in prestashop documentation).
 
TITLE:
Nginx Rewrite issue​
PRODUCT, VERSION, OPERATING SYSTEM, ARCHITECTURE:
Plesk Onyx​
PROBLEM DESCRIPTION:
I was trying to use my typical rewrights for prestashop, but somehow there is an issue setting it.

Some of the vars are removed from the string and that makes it fail.

rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

It removes $1 and $2​
STEPS TO REPRODUCE:
Try and enter

rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

To the nginx config area.​
ACTUAL RESULT:
Removes needed vars​
EXPECTED RESULT:
Expected result is it saves rewrite "^/module/([_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)$" /index.php?fc=module&module=$1&controller=$2 last;

Since it works with nginx.​
ANY ADDITIONAL INFORMATION:
​
YOUR EXPECTATIONS FROM PLESK SERVICE TEAM:
Help with sorting out​

@Soren,

I am pretty sure that your regexp is the root cause of the problem.

Nevertheless, you should never use a rewrite like this.

In essence, @virtubox is right and you can (which is not equivalent to "should") use the try_files directive.

In that directive, one certainly does not want to specify the full and problematic url: one should pass the (Nginx default) $request_uri variable.

In general, I would recommend to change the whole line of Nginx code.

After all, the current line is more or less saying: when matched with directory modules (or any of it's subdirectories), go to index.php and pass the request parameters.

Can you provide us with a full example of a full request_uri (as specificied by Prestashop) AND a full request URL (as beautified by your current Nginx config)?

Regards...........
 
Back
Top