Welcome! Log In Create A New Profile

Advanced

How do I rewrite files, but only, if they are in one special folder?

December 11, 2016 12:05PM
Hi guys,

I am new to nginx and I need to do a few rewrites, which I need help with.

I currently have this configuration:

location ~ \.php5 {
root /home/$username/www/;
rewrite ^/(.*)\.php5 /$1.php permanent;
}

The problem with this is that it rewrites the files, also if they are in subfolders - and this is what I do not want.

I have a root folder and inside it there is a folder called wiki/.

php5 files from inside one of these two folders should get rewritten to php files.

E.g. the file /api.php5 should get rewritten to /api.php.
File /wiki/load.php5 should get rewritten to /wiki/load.php.
But file /wiki/some-subfolder/file.php5 should *not* get rewritten, because it is neither in the root folder nor in wiki/ directly, but in one of the subfolders of wiki. Files from subfolders should *not* get rewritten.

How can I get that?

Joerg
Subject Author Posted

How do I rewrite files, but only, if they are in one special folder?

Joergi December 11, 2016 12:05PM

Re: How do I rewrite files, but only, if they are in one special folder?

Francis Daly December 12, 2016 04:20PM

Re: How do I rewrite files, but only, if they are in one special folder?

Joergi December 13, 2016 01:29PM

Re: How do I rewrite files, but only, if they are in one special folder?

Francis Daly December 29, 2016 05:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready