nginx下TP5 隐藏入口文件+支持pathinfo模式+配置多项目根目录
首先说下项目目录情况 跟目录/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模式+配置多项目根目录的更多相关文章
- Ubuntu下TP5隐藏入口文件
部分内容是复制其他网友的博文,由于过了一段时间,找不到原文地址,再次表示感谢.以下是自己整理的,目的只是以后方便查阅 1.ubuntu或linux下找不到apache服务器配置文件httpd.conf ...
- tp5隐藏入口文件(基于nginx)
location / { try_files $uri $uri/ /index.php?$query_string; #这项配置解决访问根目录以外路径报404的错误 ...
- thinkphp5 隐藏入口和支持pathinfo
url里public目录的隐藏 其实正常思路的话这个url里的public本身就是不存在的,然后呢,其实也不叫隐藏public目录,这里只是考虑到有些童鞋可能还会按之前3.x时代的习惯来配置网站根目录 ...
- TP5隐藏入口文件
1,进入根目录,打开public文件夹,里面有个.htaccess文件 2,将这段代码改成?s= 3,不修改该文件,想要隐藏入口文件则会报错 4,改了文件之后是 5,改了入口文件为了隐藏 .php
- TP5 隐藏入口文件 index.php
找到public下的.htaccess <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine ...
- Nginx 虚拟主机下支持Pathinfo并隐藏入口文件的完整配置
server { listen 80; server_name zuqiu.com; # 设置你的域名 index index.html index.htm index.php; root D:/wn ...
- TP5 多入口文件配置的坑
闲话不多说,TP5(5.0.20) 在配置多入口文件的时候你是否遇到过一下的问题呢? 开发设计的需求吧网站拆分为前台.后台.API 3 个模块,对应的也需要3个入口文件,后台和API入口文件是用PAT ...
- CI 框架怎么去掉隐藏入口文件 index.php
当我重新接触一个框架的时候首先肯定要去掉入口文件,也就是index.php 这个东西在url上很不漂亮,而且每次我访问我的网站的时候都要打进去url里面.这样告诉一个去掉 CI框架里面入口文件的方法, ...
- nginx低版本不支持pathinfo模式,thinkphp针对此问题的解决办法
将一个thinkphp项目从apache环境移到nginx1.2上,怎奈,nginx这个版本默认不支持pathinfo模式 首先,编辑nginx的虚拟主机配置文件 location ~ .*.(php ...
随机推荐
- bzoj 1863: [Zjoi2006]trouble 皇帝的烦恼【二分+dp】
二分答案,注意l是max(a[i]+a[i+1]),r是sum_a 判断的时候用dp,设f[i]为i与1最少的相同颜色数,g[i]为i与1最多的相同颜色数,转移是f[i]=max(a[i]-(w-a[ ...
- 4800: [Ceoi2015]Ice Hockey World Championship(折半搜索)
4800: [Ceoi2015]Ice Hockey World Championship Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 622 S ...
- 'ALTER TABLE SWITCH' 语句失败。表'MGXXX.dbo.user_XXX' 已分区,但 索引'ix_user_XXX_user_id' 未分区。
问题描述: 今天在做分区切换的时候把旧log数据切到clear表,遇到了这个问题,顺便做下笔记记录一下解决方法 'ALTER TABLE SWITCH' 语句失败.表'MGXXX.dbo.user_X ...
- 实现简单版的LinkedList
相比ArrayList,双链表的数据结构就复杂多了,想要弄清代码的意思还是要搞清数据结构层面的变化. package cn.sp.chapter03; import java.util.Concurr ...
- quickpow || 快速幂
洛谷例题 推荐自行脑补:百度百科 如果 ,那么 : 前言:快速幂就是快速算底数的n次幂.其时间复杂度为 O(log₂N), 与朴素的O(N)相比效率有了极大的提高. 拿题目样例 Input :2 1 ...
- python爬虫爬取汽车页面信息,并附带分析(静态爬虫)
环境: windows,python3.4 参考链接: https://blog.csdn.net/weixin_36604953/article/details/78156605 代码:(亲测可以运 ...
- SQL 初级教程学习(五)
1.DEFAULT 约束用于向列中插入默认值. CREATE TABLE Orders(Id_O int NOT NULL,OrderNo int NOT NULL,Id_P int,OrderDat ...
- django templates模板
Django templates模板 HTML代码可以被直接硬编码在views视图代码中,虽然这样很容易看出视图是怎么工作的,但直接将HTML硬编码到视图里却并不是一个好主意. 让我们来看一下为什么: ...
- ACM输入外挂
一.什么是输入挂 scanf的输入速度不cin快得多,那么有没有比scanf更快的东西呢?这就是要用到输入挂了. 二.什么时候使用输入挂 当输入规模达到1x10^6次方的时候,就需要输入挂,否则很可能 ...
- Service官方教程(8)Bound Service示例之2-跨进程使用Messenger
Compared to AIDL When you need to perform IPC, using a Messenger for your interface is simpler than ...