首先说下项目目录情况  跟目录/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. bzoj 5195: [Usaco2018 Feb]Directory Traversal【树形dp】

    注意到目录是一颗树结构,然后就简单了,预以1为根的处理出dis[u]为以这个点为根,到子树内的目录总长,si为子树内叶子数 第二遍dfs换根即可 #include<iostream> #i ...

  2. [Swift通天遁地]一、超级工具-(5)使用UIWebView(网页视图)加载本地页面并调用JavaScript(脚本)代码

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  3. Ubuntu 18.04 LTS 系统设置打不开了

    在更换软件源后,安装了vim 和chrome,chrome很顺利,但是安装vim的时候后就显示有问题了,有的依赖版本不对,嫌版本太高,卸载后再装可以. 安装了python和python2 依旧是有些依 ...

  4. javascript匿名方法

    首先,看一段很有意思的代码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> < ...

  5. Windows查杀端口

    Windows环境下当某个端口被占用时,通过netstat命令进行查询pid,然后通过taskkill命令杀进程. 一.查询占用端口号的进程信息 netstat -an|findstr 二.杀掉占用端 ...

  6. ssm(Spring、Springmvc、Mybatis)实战之淘淘商城-第五天(非原创)

    文章大纲 一.课程介绍二.前台系统(门户系统)搭建介绍三.前台系统(门户系统)搭建实战四.js请求跨域解决五.项目源码与资料下载六.参考文章   一.课程介绍 一共14天课程(1)第一天:电商行业的背 ...

  7. 三种将list转换为map的方法(传统方法、jdk8 Stream流、guava)

    三种将list转换为map的方法 - jackyrong - ITeye博客:http://jackyrong.iteye.com/blog/2158009

  8. CCF|游戏|Java

    import java.util.Scanner; public class tyt { public static void main(String[] args) { Scanner in = n ...

  9. greendao3.2.3配置时遇到的问题

    这两天我一直在研究greendao这个框架,我在GitHub下载了 greendao3.2.2:https://github.com/greenrobot/greenDAO,照着网址里面来配置: // ...

  10. 详解Android Activity启动模式

    相关的基本概念: 1.任务栈(Task)   若干个Activity的集合的栈表示一个Task.   栈不仅仅只包含自身程序的Activity,它也可以跨应用包含其他应用的Activity,这样有利于 ...