首页 > 解决方案 > 未找到带有 Wordpress 子目录页面的 Nginx IFSC 代码脚本

问题描述

这是有效的

https://example.com/ifsc-code/index.php?bank=axis-bank&state=west-bengal&district=kolkata&branch=bally

这显示错误404

https://example.com/ifsc-code/axis-bank/west-bengal/kolkata/bally

我在 Nginx.conf 文件中使用此代码

location /ifsc-code {
    try_files $uri $uri/ /index.php?$args;
    rewrite ^/(.*)/(.*)/(.*)/(.*)/?$ /index.php?bank=$1&state=$2&district=$3&branch=$4;
    rewrite ^/(.*)/(.*)/(.*)/?$ /index.php?bank=$1&state=$2&district=$3;
    rewrite ^/(.*)/(.*)/?$ /index.php?bank=$1&state=$2;
    rewrite ^/(.*)/?$ /index.php?bank=$1;
}

标签: wordpressnginx

解决方案


我更改了代码,我的问题已经解决,希望对某人有所帮助。

location  /ifsc-code {
                 root /var/www/example/ifsc-code; 
                 index index.php index.html index.htm;
                 try_files $uri $uri/ @ifsc-code;
}
        
location @ifsc-code {
                rewrite ^/ifsc-code/(.*)/(.*)/(.*)/(.*)/?$ /ifsc-code/index.php?bank=$1&state=$2&district=$3&branch=$4;
                rewrite ^/ifsc-code/(.*)/(.*)/(.*)/?$ /ifsc-code/index.php?bank=$1&state=$2&district=$3;
                rewrite ^/ifsc-code/(.*)/(.*)/?$ /ifsc-code/index.php?bank=$1&state=$2;
                rewrite ^/ifsc-code/(.*)/?$ /ifsc-code/index.php?bank=$1;
}

推荐阅读