모든 경로에 액세스하는 문제를 해결하는 것은 홈페이지입니다.

모든 경로에 액세스하는 문제를 해결하는 것은 홈페이지입니다.

1. nginx.conf 구성 수정

location ~ \.php {
   fastcgi_pass   127.0.0.1:9000;
   fastcgi_index  index.php;
   fastcgi_split_path_info ^(.+\.php)(.*)$;
   fastcgi_param  PATH_INFO $fastcgi_path_info;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   include        fastcgi_params;
}
location / { #去掉$
   if ( -f $request_filename) {
       break;
   }
   if ( !-e $request_filename) {
       rewrite ^(.*)$ /index.php/$1 last;
       break;
   }
   #新增
   try_files $uri $uri/ /index.php?$query_string;
}

2. 아파치의 .htaccess 파일 수정

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/?$1 [QSA,PT,L]  #注意多了?号
</IfModule>

3. 프로젝트의 config.php에서 pathinfo_fetch를 수정합니다.

프로젝트 구성 config.php에서 pathinfo_fetch를 수정하고 끝에 REQUEST_URI를 추가합니다.

// PATH_INFO와 호환되는 'pathinfo_fetch'가져 오기 => [ 'ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL', 'REQUEST_URI'],

4. .htaccess 파일 수정

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]</IfModule>

추천

출처blog.csdn.net/qq_44255146/article/details/115142613