I have migrated my website from Apache to Nginx. I had issue after migration.
Current .htaccess configuration:
RewriteBase /
RewriteRule ^home$ index.php
RewriteRule ^file/? do.php?id= [QSA]
RewriteCond %{QUERY_STRING} ^(.*)id(.*)$
RewriteRule ^img/?([0-9]*)$ do.php?%1img%2
RewriteCond %{QUERY_STRING} ^fileid=(.*)$
RewriteRule ^download/? do.php?down=%1 [QSA,L]
Before Rewrite URLs:
URL for Image download: https://www.example.com/do.php?img=xx
URL for File download: https://www.example.com/do.php?id=xx
After Rewrite URLs:
URL for Image download: https://www.example.com/img?id=xx
URL for File download: https://www.example.com/download?id=xx
And all working fine on apache Never faced any issue.
While in Nginx, I used this configuration:
rewrite ^/home$ /index.php ;
rewrite ^/file/? /do.php?id= ;
if ($args ~ "^(.*)id(.*)$"){
set $rule_2 1;
set $bref_2_0 $1;
set $bref_2_1 $2;
}
if ($rule_2 = "1"){
rewrite ^/img/?([0-9]*)$ /do.php?${bref_2_0}img${bref_2_1} ;
}
if ($args ~ "^fileid=(.*)$"){
set $rule_3 1;
set $bref_3_0 $1;
}
if ($rule_3 = "1"){
rewrite ^/download/? /do.php?down=${bref_3_0} last;
}
Now when I try to access https://www.example.com/download?fileid=135759 I get ERR_TOO_MANY_REDIRECTS.
Please help.