首先说下项目目录情况  跟目录/usr/share/nginx/html/(别说怎么这么深  0.0)

html文件夹下面两个目录 pssh  pssh_shop 两个tp5项目分别对应两个二级域名

配置多项目就把server{} 在复制出来一套 修改对应的root路径就可以

下面放上配置文件(只有域名2那个项目隐藏入口文件了 )

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 20M; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; server { listen 80;
server_name 域名1;
location / {
root /usr/share/nginx/html/pssh/public/;
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html/pssh/public/;
}
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html/pssh/public/;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# location ~ \.php($|/) {
root /usr/share/nginx/html/pssh/public/;
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;
} } server { listen 80;
server_name 域名2;
#匹配url中server_name之后的部分
location / {
root /usr/share/nginx/html/pssh_shop/public/;
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
#重写url 为了隐藏index.php
if ( !-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html/pssh_shop/public/;
}
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html/pssh_shop/public/;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# location ~ \.php($|/) {
root /usr/share/nginx/html/pssh_shop/public/;
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;
} } # Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# } }

上面配置完  tp5的public目录下的.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>

我是这么配置好用了 , 也不清楚这么写对不对 正不正规。记录下就是为了方便以后再用。不喜勿喷。谢谢

nginx下TP5 隐藏入口文件+支持pathinfo模式+配置多项目根目录的更多相关文章

  1. Ubuntu下TP5隐藏入口文件

    部分内容是复制其他网友的博文,由于过了一段时间,找不到原文地址,再次表示感谢.以下是自己整理的,目的只是以后方便查阅 1.ubuntu或linux下找不到apache服务器配置文件httpd.conf ...

  2. tp5隐藏入口文件(基于nginx)

    location / {             try_files $uri $uri/ /index.php?$query_string; #这项配置解决访问根目录以外路径报404的错误      ...

  3. thinkphp5 隐藏入口和支持pathinfo

    url里public目录的隐藏 其实正常思路的话这个url里的public本身就是不存在的,然后呢,其实也不叫隐藏public目录,这里只是考虑到有些童鞋可能还会按之前3.x时代的习惯来配置网站根目录 ...

  4. TP5隐藏入口文件

    1,进入根目录,打开public文件夹,里面有个.htaccess文件 2,将这段代码改成?s= 3,不修改该文件,想要隐藏入口文件则会报错 4,改了文件之后是 5,改了入口文件为了隐藏  .php

  5. TP5 隐藏入口文件 index.php

    找到public下的.htaccess <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine ...

  6. Nginx 虚拟主机下支持Pathinfo并隐藏入口文件的完整配置

    server { listen 80; server_name zuqiu.com; # 设置你的域名 index index.html index.htm index.php; root D:/wn ...

  7. TP5 多入口文件配置的坑

    闲话不多说,TP5(5.0.20) 在配置多入口文件的时候你是否遇到过一下的问题呢? 开发设计的需求吧网站拆分为前台.后台.API 3 个模块,对应的也需要3个入口文件,后台和API入口文件是用PAT ...

  8. CI 框架怎么去掉隐藏入口文件 index.php

    当我重新接触一个框架的时候首先肯定要去掉入口文件,也就是index.php 这个东西在url上很不漂亮,而且每次我访问我的网站的时候都要打进去url里面.这样告诉一个去掉 CI框架里面入口文件的方法, ...

  9. nginx低版本不支持pathinfo模式,thinkphp针对此问题的解决办法

    将一个thinkphp项目从apache环境移到nginx1.2上,怎奈,nginx这个版本默认不支持pathinfo模式 首先,编辑nginx的虚拟主机配置文件 location ~ .*.(php ...

随机推荐

  1. P5107 能量采集

    传送门 官方题解 话说最后的答案忘记取模了结果连暴力都挂了可海星-- //minamoto #include<bits/stdc++.h> #define R register #defi ...

  2. 【插件开发】—— 12 GEF入门

    介绍 前面也简单的介绍了一下插件开发的相关知识,下面主要就介绍一下GEF的相关使用.由于最近使用到编辑器这部分的操作,因此就跳过其他的内容,先介绍下GEF的相关知识. 前文回顾 1 插件学习篇 2 简 ...

  3. InputFilter在过滤空格时重复输入的问题

    正确做法:editText.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filte ...

  4. bzoj1233 [Usaco2009Open]干草堆tower 【单调队列dp】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1233 单调队列优化的第一题,搞了好久啊,跟一开始入手斜率优化时感觉差不多... 这一题想通了 ...

  5. Linux的proc文件系统 分类: linux 2014-06-02 10:21 623人阅读 评论(0) 收藏

    proc为一个内核数据结构接口,用户空间和内核空间可以通过该接口通信, 与普通文件不同的是,这些虚拟文件的内容都是动态创建的. proc文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间. ...

  6. 222 Count Complete Tree Nodes 完全二叉树的节点个数

    给出一个完全二叉树,求出该树的节点个数.完全二叉树的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置.若最底层为第 h ...

  7. javascript 笔记--变量

    用了这么久的Javascript,该总结下了!温故而知新! var 声明变量: javascript 是弱类型语言,因此无需为声明对象明确类型声明. 如:var test="字符串" ...

  8. APK瘦身-是时候给App进行减负了

    前言 APK瘦身即是对APK大小进行压缩策略,减小APK安装包大小,更小的安装包更有助于吸引用户安装.前一段时间我司某一App进行APK的瘦身,最终也达到了减小10M的目标,现做一个简单的总结记录. ...

  9. Selenium--Python环境部署

    本文引读:一二为python环境安装:三为selenium安装同时介绍了pip:四为PyCharm安装:五为验证SE可以正常使用 一.下载python安装包 我这里安装的是python3.6.5,官网 ...

  10. JS中的对象之原型

    对象 ECMAScript做为一个高度抽象的面向对象语言,是通过_对象_来交互的.即使ECMAScript里边也有_基本类型_,但是,当需要的时候,它们也会被转换成对象. 一个对象就是一个属性集合,并 ...