Nginx makes the root directory url automatically jump to rootpath/index.html, how to force the jump to index.html?

when you ask this question, you usually give the answer to these questions
1, how the nginx server removes the index.php in url
2, how the nginx server URL cannot automatically add index.php
3, and how nginx hides the index.php or .php path

.

what I want to achieve now is to access the directory to force 301 to the directory / index.html or path/index.php,
but: other resource paths remain completely the same
for example:

  1. https://www.zhoulujun.cn/zhou.
  2. https://www.zhoulujun.cn/zhou.
  3. https://www.zhoulujun.cn/zhou.
  4. https://www.zhoulujun.cn/zhou.

the actual content of the four paths is the same. I only want to keep a path , preferably: https://www.zhoulujun.cn/zhou.
implementation step:
A: how to allow users to access 1 or 2, automatically jump to 3?
method used at first:
location / zhoulujun {

rewrite ^/$ http://www.zhoulujun.cn/zhoulujun/index.php permanent;

}
however, it is found that there is a problem with other resource files under this path
B: then, put it over for implementation, and 3 jumps to 1 or 2.
location zhoulujun/index. (html | php) {

    rewrite https://www.zhoulujun.cn/zhoulujun/$is_args$args permanent;
}

however, the measured result is that it stops at 301, then the browser stops refreshing and the load fails.

Baidu and Google"s answers are all
location / {

            try_files $uri $uri index.php;
    }

more
location / {

below Google"s answer
    if ( !-e $request_filename ) {
      proxy_pass      http://index;
    }

}
    
    

none of the results can be realized.
, kneel down and answer, thank you


location /zhoulujun {
    rewrite ^/(.*)$ http://www.zhoulujun.cn/zhoulujun/index.php permanent;
}

location / {
    ...
}

is that what you want?

Menu