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 ...
随机推荐
- 「vijos」lxhgww的奇思妙想(长链剖分)
传送门 长链剖分的板子(又是乱搞优化暴力) 对于每一个点,我们定义它深度最深的子节点为它的重儿子(为什么不叫长儿子……),他们之间的连边为重边 然后长链剖分有几个性质 1.总链长为$O(n)$ 2.一 ...
- codeforces 570 E. Pig and Palindromes (DP)
题目链接: 570 E. Pig and Palindromes 题目描述: 有一个n*m的矩阵,每个小格子里面都有一个字母.Peppa the Pig想要从(1,1)到(n, m).因为Peppa ...
- git 标签
如果你达到一个重要的阶段,并希望永远记住那个特别的提交快照,你可以使用 git tag 给它打上标签. 比如说,我们想为我们的 runoob 项目发布一个"1.0"版本. 我们可以 ...
- Proactive Patching Overview
1.Proactive Patching Overview Between Patch Set releases, Oracle's proactive patching program provid ...
- 一个简单的jsp+servlet登录界面的总结
这个登录界面我是用eclipse+tomcat7来实现的(网上比较多都是用myeclipse来做的) 1.首先是关于servlet部署的问题 首先你的servlet类要写在WEB-INF的Class文 ...
- leetcode 484. Find Permutation 思维题
https://leetcode.com/contest/leetcode-weekly-contest-16a/problems/find-permutation/ 设原本的数字是0,那么按照它的D ...
- c#中stringbuilder的方法总结
String 对象是不可改变的.每次使用 System.String 类中的方法之一时,都要在内存中创建一个新的字符串对象,这就需要为该新对象分配新的空间.在需要对字符串执行重复修改的情况下,与创建新 ...
- Java对象创建
今天发现一个问题: 如果加上第一个输出,那么两个per1的对象是不一样的,如果不加,那么下一个输出的对象的是和第一个是一致的? 思考为什么???? 代码如下: package com.lgq.serv ...
- hihocoder 神奇字符串
思路: 暴力,模拟. 实现: #include <iostream> #include <algorithm> #include <cstdio> #include ...
- CCF|碰撞的小球
import java.util.Scanner; public class Main { public static void main (String[] args) { Scanner scan ...