Welcome! Log In Create A New Profile

Advanced

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

Francis Daly
December 12, 2016 04:20PM
On Sun, Dec 11, 2016 at 12:05:19PM -0500, Joergi wrote:

Hi there,

> 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.

You don't say what you want to happen to those other files, so I will
leave it at "nothing special".

Just rewrite what you want to. That is: no-slash, or /wiki/ then no-slash.

rewrite ^/([^/]*)\.php5 /$1.php permanent;
rewrite ^(/wiki/[^/]*\.php)5 $1 permanent;

Untested, but it looks right :-)

You may want to restrict these to the locations that match their prefixes,
depending on what else is happening.

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
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: 313
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready