任意のパスにアクセスする問題を解決するのはホームページです

任意のパスにアクセスする問題を解決するのはホームページです

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.apacheの.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
おすすめ