当前位置: 代码迷 >> 综合 >> ubuntu LNMP nginx 隐藏index.php 配置文件
  详细解决方案

ubuntu LNMP nginx 隐藏index.php 配置文件

热度:98   发布时间:2023-12-12 01:35:52.0

创建/编辑配置文件

#(自己设置虚拟主机的配置文件)
vi /etc/nginx/site-available/www.myredis.local.com
server {listen 80;root /var/www/html/tp3;index index.html index.htm index.php;server_name www.myredis.local.com;location / {index index.html index.php;	try_files $uri $uri/ =404;if (!-e $request_filename) {rewrite ^(.*)$ /index.php?s=$1 last;#rewrite ^/(.*)$ /index.php?s=$1 last;break;}autoindex on;}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {fastcgi_pass unix:/run/php/php7.0-fpm.sock;fastcgi_index index.php;#fastcgi_split_path_info ^(.+\.php)(.*)$;fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;include fastcgi_params;}}

保存退出。

ln -s /etc/nginx/site-available/www.myredis.local.com /etc/nginx/site-enabled/

重启nginx

service nginx restart

 

  相关解决方案