Nginx 转写功能和Apache .htaccess 对应
之前一直使用apache 服务器,现有一项目想转到Nginx 服务器运行。。
发现Apache 的撰写功能和 Nginx的不一样。无法通用.hataccess 文件
查阅网上资料,nginx 配置转写功能 是直接在配置文件中 配置的:
虚拟服务器设置:
server {
listen ;
server_name localhost:;
root "D:/phpStudy/WWW/yii2/anran/backend/web";
location / {
index index.html index.php;#默认主页
autoindex on;#是否允许访问目录
include D:/phpStudy/WWW/yii2/anran/backend/web/.htaccess; #关键htaccess 导入
}
#php 解析器
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
其中
include D:/phpStudy/WWW/yii2/anran/backend/web/.htaccess; #关键htaccess 导入
是由apache 的.htaccess 转化过来的 网址:http://winginx.com/en/htaccess
原.htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
转换后.htaccess (就是nginx导入的配置)
if (!-e $request_filename){
rewrite ^(.*)$ /index.php;
}
Nginx 转写功能和Apache .htaccess 对应的更多相关文章
- Apache .htaccess文件
今天在将ThinkPHP的URL模式由普通模式(URL_MODE=1)http://localhost/mythinkphp/index.php/Index/user/id/1.html改为重写模式 ...
- 为什么Nginx的性能要比Apache高很多?
为什么Nginx的性能要比Apache高很多? 这得益于Nginx使用了最新的epoll(Linux 2.6内核)和kqueue(freebsd)网络I/O模型,而Apache则使用的是传统的sele ...
- Nginx启动SSL功能
Nginx启动SSL功能,并进行功能优化,你看这个就足够了 一:开始Nginx的SSL模块 1.1 Nginx如果未开启SSL模块,配置Https时提示错误 nginx: [emerg] the &q ...
- Nginx代理缓存功能
Nginx代理缓存功能 Nginx缓存主要是用于减轻后端服务器的负载,提高网站并发量,提升用户体验度. 注意:Nginx反向代理的缓存功能是由ngx_http_proxy_module提供, ...
- Nginx Rewrite相关功能
目录 Nginx Rewrite相关功能 ngx_http_rewrite_module模块指令: if指令: set指令: break指令: return指令: rewrite_log指令: rew ...
- nginx前端负载,后端apache获取真实IP设置
原文链接: nginx前端负载,后端apache获取真实IP设置 参考文献: 前端Nginx,后端Apache获取用户真实IP地址 按照第二种方法设置不成功! 网站最前端是nginx,做的PROXY ...
- Nginx 状态信息功能配置
Nginx 状态信息功能介绍 Nginx 有一个 ngx_http_stub_status_module 模块,主要功能是记录 Nginx 的基本访问状态信息,让使用者了解 Nginx 的工作状态 要 ...
- 启动Nginx目录浏览功能及 让用户通过用户名密码认证访问web站点
一.启动Nginx目录浏览功能 [root@abcdocker extra]# cat w.conf server { listen 80; server_name IP地址; location / ...
- 镜像回源主要用于无缝迁移数据到OSS,即服务已经在自己建立的源站或者在其他云产品上运行,需要迁移到OSS上,但是又不能停止服务,此时可利用镜像回写功能实现。
管理回源设置_管理文件_开发指南_对象存储 OSS-阿里云 https://help.aliyun.com/document_detail/31865.html 通过回源设置,对于获取数据的请求以多种 ...
随机推荐
- C# 数据类型之间的转换
C数据类型转换 https://www.cnblogs.com/bluestorm/p/3168719.html 1 字符串解析为整数: a = int.Parse (Console.ReadLine ...
- Java虚拟机最多支持多少个线程?
作者:miracle1919 来源:http://sina.lt/getP McGovernTheory在StackOverflow提了这样一个问题:Java虚拟机最多支持多少个线程?跟虚拟机开发商 ...
- 一份完整的 MySQL 开发规范,进大厂必看!
作者:听风 https://www.cnblogs.com/huchong/p/10219318.html 一.数据库命令规范 1.所有数据库对象名称必须使用小写字母并用下划线分割 2.所有数据库对象 ...
- HTMLTestRunner_PY3脚本代码
HTMLTestRunner_PY3.py文件代码如下: # -*- coding: utf-8 -*- """ A TestRunner for use with th ...
- 网页中<a>标签新窗口和location.href 新窗口打开
在网页制作过程中,经常遇到新窗口打开,一般是a超级链接或者location.href 新窗口打开形式,下面分别讲述两种之间的不同方式 1,a标签 新窗口 添加属性 target="_blan ...
- 修复线上bug
1,git branch new_branch 2,git push origin new_branch 以上是线上地址操作,以下是本地仓库操作 3,git fetch 4,git checkout ...
- ListView鼠标拖
private Point Position = new Point(0, 0); private void treeFileView_ItemDrag(object sender, ItemDrag ...
- C#中的==和Equals的区别
一,值类型中的比较,对于值类型,如果对象的值相等,则相等运算符 (==) 返回 true,否则返回 false. ; ; bool bi1 = ai.Equals(bi); //true bool b ...
- iOS 证书(.p12)和描述文件(.mobileprovision)的导出和使用方法
为什么要导出.p12文件 当我们用大于三个mac设备开发应用时,想要申请新的证书,如果在我们的证书里,包含了3个发布证书,2个开发证书,可以发现再也申请不了开发证书和发布证书了(一般在我们的证书界面中 ...
- 树——minimum-depth-of-binary-tree(二叉树的最小深度)
问题: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the s ...