nginx重写与重定向区别_nginx 匹配(重定向)
文件供参考(有点乱)
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$upstream_addr" "$upstream_response_time" "$request_time"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
if ( $host = '192.168.0.88' ){
# default_type 'text/html';
#echo $QUERY_STRING;
rewrite ^/(.*)$ http://opq.renqibaohe.com/$1 permanent ;
}
#limit_conn test 1;
#charset koi8-r;
#access_log logs/host.access.log main;
rewrite /image/tmig.jpg /img/tmig.jpg break;
location /hello {
# default_type 'text/html';
# echo $QUERY_STRING;
# set $u $document_root$fastcgi_script_name;
# echo $u;
root /www;
index index.html;
rewrite ^/image/(.*)$ /img/$1 last;
# if ( !-d $u ) {
# return 404;
# }
}
location =/index.html {
root /www;
default_type 'text/html';
echo $document_root$fastcgi_script_name;
index aa.html index.html index.htm;
}
#location = / {
# proxy_pass http://www.baidu.com;
#}
location /{
root html ;
default_type 'text/html'; #如果没有这个default_type,则会一直下载文件而不是输出在浏览器上
#echo $echo_client_request_headers;
#echo_read_request_body;
#echo $request_body;
echo $http_user_agent;
if ( $http_user_agent ~ Trident ){
rewrite ^.* index.html;
break;
# return 404;
}
if ( $remote_addr = '192.168.0.107'){
echo "delay";
}
if ( -e $document_root$fastcgi_script_name ) {
#echo $document_root$fastcgi_script_name;
#rewrite ^.* index.html;
return 404;
# break;
}
echo $request_method;
echo 'fjslfdjdslfjs';
index index.php;
}
location /index.html{
root html;
index index.html;
}
#location ~ image {
# rewrite ^/image/(.*) /img/$1 last;
# root /www;
#}
location /foo {
default_type 'text/html'; #如果没有这个default_type,则会一直下载文件而不是输出在浏览器上
echo 'fsfsd';
#if($host != '192.168.0.107'){
#default_type 'text/javascript'; #如果没有这个default_type,则会一直下载文件而不是输出在浏览器上
# echo $echo_client_request_headers;
# echo_read_request_body;
# echo $request_body;
#}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
# location =/1.html{
#
# root /usr/local/nginx/html;
# limit_req zone=allips burst=5 nodelay;
# }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
echo "delay";
}
if ( -e $document_root$fastcgi_script_name ) {
#echo $document_root$fastcgi_script_name;
#rewrite ^.* index.html;
return 404;
# break;
}
echo $request_method;
echo 'fjslfdjdslfjs';
index index.php;
}
location /index.html{
root html;
index index.html;
}
#location ~ image {
# rewrite ^/image/(.*) /img/$1 last;
# root /www;
#}
location /foo {
default_type 'text/html'; #如果没有这个default_type,则会一直下载文件而不是输出在浏览器上
echo 'fsfsd';
#if($host != '192.168.0.107'){
#default_type 'text/javascript'; #如果没有这个default_type,则会一直下载文件而不是输出在浏览器上
# echo $echo_client_request_headers;
# echo_read_request_body;
# echo $request_body;
#}
}
nginx重写与重定向区别_nginx 匹配(重定向)相关推荐
- nginx重写与重定向区别_nginx学习十一 rewrite url重写以及重定向
语法 Syntax:rewrite regex replacement [flag]; Default: -- Context:server,location,if ## 其中 flag 有: ## ...
- 实例演示Nginx重写(Rewrite)类型last、break、redirect和permanent的区别
本文使用之前制作的Docker容器<<Docker案例:搭建nginx服务>>演示Nginx四种重写类型的区别和效果,如果尚未构建Docker服务可参考之前的文章,或者自建Ng ...
- Nginx 之四: Nginx服务器的rewrite、全局变量、重定向和防盗链相关功能
一:Nginx 后端服务器组的配置: 1.upstream: 用于设置后端服务器组的主要指令,upstream类似于之前的server块或http块,用法如下: upstreame Myserver{ ...
- php重定向和伪静态,PHP重定向与伪静态的区别详解
伪静态是SEO重要的方法,通过重定向来实现,并且可以通过重定向来隐藏网站的技术,过滤异常访问.本课分为两部分,前半部分详细介绍Apache重定向的基础知识,后半部分通过多个实际案例再次加深对重定向的理 ...
- php重定向什么意思,PHP重定向与伪静态区别
什么是伪静态 伪静态是相对真静态来讲 伪静态只是把URL改成静态形式,实际上还是动态网页 伪静态有着真静态一样的SEO 什么是重定向(很常用重点学习) 将网络请求重新定一个方向,转到别的位置 分为内部 ...
- ServletRequest HttpServletRequest 请求方法 获取请求参数 请求转发 请求包含 请求转发与重定向区别 获取请求头字段...
原文地址:ServletRequest HttpServletRequest 请求方法 获取请求参数 请求转发 请求包含 请求转发与重定向区别 获取请求头字段 ServletRequest 基本概念 ...
- 请求转发和重定向的区别_WEB之重定向和请求转发的区别
一次重定向的过程 我的代码里面已经写好了,redirectAndFoward.jsp页面上有一个表单,表单重定向到redirectAndFowardTarget.jsp,那么这一次的重定向过程为: 1 ...
- nginx 监听非标准端口80,重定向端口丢失问题解决
nginx 监听非标准端口80,重定向端口丢失问题解决 参考文章: (1)nginx 监听非标准端口80,重定向端口丢失问题解决 (2)https://www.cnblogs.com/qianxunm ...
- 微博快捷登录提示21322重定向地址不匹配(解决方案)
微博快捷登录提示21322重定向地址不匹配(解决方案) 微博快捷登录提示21322重定向地址不匹配(解决方案) 微博快捷登录提示21322重定向地址不匹配(解决方案) 1.微博网页应用授权报错,代码: ...
最新文章
- 市面上不成熟的系统Java_回顾java基础知识
- matlab从flove,Matlab玩出新高度,变身表白女友神器_善良995的博客-CSDN博客
- 5G中网络切片技术是什么?—Vecloud
- (转)OpenNLP进行中文命名实体识别(下:载入模型识别实体)
- RGB ECT 4BIT 压缩后质量远高于RGB ETC2 4BIT
- [scala-spark]1. Spark vs Hadoop 及 基础
- 选择or不选择苹果的理由
- Spring Data JPA使用
- 应用层协议:HTTPS
- 怎么把组件挂载到body上_Vue2和Vue3使用上的区别在这,耗子尾汁!
- linux硬盘怎么分配合适,500G的硬盘,怎么分区比较合理?
- 将Excel数据批量导入到数据库(项目案例)
- 锐捷设备AC旁挂核心交换机①
- 安卓9安装xpose
- 正点原子STM32F103(精英版)------电容触摸按键
- 在TMS320F2812上实现从flash拷贝整个程序到RAM上运行的方法探讨
- CJT长江连接器公司的A2541系列线对板连接器PCB封装库
- 我觉得,我认为。。。
- 洛谷 P3387 缩点 题解
- 594. 最长和谐子序列--Python