I have an old PHP application running with Apache, for now I need to switch to use Nginx
htaccess redirecting rule
php_value upload_max_filesize "5M"
AddType text/x-component .htc
RewriteEngine On
RewriteBase /brand/kit/summer-icecream/lacne
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(/admin/)
RewriteCond %{REQUEST_URI} !(/setup/)
RewriteCond %{REQUEST_URI} !(/support/)
RewriteCond %{REQUEST_URI} !(/share/)
RewriteCond %{REQUEST_URI} !(/rss/)
RewriteCond %{REQUEST_URI} !(/output/)
RewriteCond %{REQUEST_URI} !(/upload/)
RewriteCond %{REQUEST_URI} !(/app_api/)
RewriteRule ^(.+)\.php$ share/admin/$1.php [L]
RewriteRule app_api/(.+)\.php$ share/app_api/$1.php [L]
I have tried several way to redirect such as below but it seems doesn't work at all, it doesn't pass the PHP file to PHP-FPM
location ~ brand/kit/summer-icecream/lacne/(.+)\.php$ {
if (!-e $request_filename){
rewrite ^/brand/kit/summer-icecream/lacne/(.+)\.php$ /brand/kit/summer-icecream/lacne/share/admin/$1.php redirect;
}
}
location ~ (.+)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param HTTP_HOST $host;
include /etc/nginx/fastcgi_config;
}
For testing, the request URI is:
http://127.0.0.1:8989/brand/kit/summer-icecream/lacne/login.php