小知识:Nginx下支持Thinkphp URL Rewrite的配置示例

概述

Nginx服务器现在已经成为相当流行的开源Web服务器,很多生产环境也都在使用Nginx服务器。现在做项目大多数时候都是在使用ThinkPHP,但是Nginx默认不支持ThinkPHP的pathinfo模式,需要进行一定的配置。

Nginx配置文件

# # The default server # server {    listen    80 default_server;    #server_name www.example.com;   #charset koi8-r;   #access_log logs/host.access.log main;   # Load configuration files for the default server block.   include /etc/nginx/default.d/*.conf;    #location / {   #  root  /usr/share/nginx/html;   #  index index.html index.htm;   #}   location / {   root      /var/www/project_name;   index index.html index.php;      if (!-e $request_filename){        rewrite ^(.*)$ /index.php?s=$1 last;      }    }    error_page 404       /404.html;    location = /404.html {      root  /usr/share/nginx/html;    }    # redirect server error pages to the static page /50x.html   #   error_page  500 502 503 504 /50x.html;    location = /50x.html {      root  /usr/share/nginx/html;    }    # proxy the PHP scripts to Apache listening on 127.0.0.1:80   #   #location ~ \.php$ {   #  proxy_pass  http://127.0.0.1;   #}   # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000   #   location ~ \.php$ {      root      /var/www/project_name;      fastcgi_pass  127.0.0.1:9000;      fastcgi_index index.php;      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;      include    fastcgi_params;    }    # deny access to .htaccess files, if Apaches document root   # concurs with nginxs one   #   #location ~ /\.ht {   #  deny all;   #}

总结

做个备份,方便以后查看:)

声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:2020年Linux系统sudo命令5个新功能

2023-5-5 2:11:18

建站知识

小知识:使用Meld在Linux中以图形方式比较文件和文件夹

2023-5-5 2:19:37

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索