I have a question concerning nginx redirects / try_files:
I have a website (vhost managed by ISPConfig3) at www.XXXYYY.com
In the root directory there are folders, index.php and so on.
I want certain files in www.XXXYYY.com/folder21/public/309273.php
to be accessible at www.XXXYYY.com/309273
(to have prettier links).
However, everything I tried yet did either not work at all or the .php-files got downloaded instead of being processed by PHP-FPM…
This is the nginx vhost directive I'm currently trying out in ISPConfig3:
This is being set by ISPConfig3:
location ~ \.php$ {
try_files @php;
}
location @php {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9026;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
This is the part that is being added by me at the bottom of the vhost-file:
location / {
try_files $uri $uri/ /folder21/public/$uri.php /index.php =404;
}
location /folder21/ { internal; }
location /folder21/public/ {
try_files $uri $uri/ $uri.php;
}
Any help on this is appreciated!
This is what I ended up with for pydio:
location /conf/ { deny all; }
location /data/ { internal; }
location /data/public/ {
try_files $uri $uri/ $uri.php?$args;
rewrite ^/data/public/([a-z0-9]+)-([a-z]+)$ /data/public/$1.php?lang=$2 last;
}
location ^~ /share/ {
rewrite ^/share/(.*)$ /data/public/$1 last;
}
PHP-files in /data/public
are now served through /share
without the need of the .php-ending.
Files in the format of e.g. /data/share/XYZ123-en
are being rewritten to/data/share/XYZ-123.php?lang=en
.