本帖最后由 乐橙306 于 2016-3-13 11:17 编辑
参考文档
HTTP rewrite 模块
http://nginx.org/en/docs/http/converting_rewrite_rules.html
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
参考文档
HTTP rewrite 模块
http://nginx.org/en/docs/http/converting_rewrite_rules.html
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html
- if ($host ~ (www.gc73.com|web.gc73.com|www.gc73.net|www.gc73.cn|web.gc73.cn|gc73.com|wy.pook.com)){
- rewrite ^/(.*)$ http://www.pook.com/$1 permanent;
- rewrite ^(.*)$ http://www.pook.com$1 permanent;
- 1.上面2条rewrite有什么区别?
- 2.~ 和 ~* 有什么区别?
0
本帖最后由 乐橙306 于 2016-3-31 14:37 编辑
建议学 nginx rewrite 模块之前 先把它看懂
正则表达式
http://www.apelearn.com/bbs/thread-11418-1-1.html
建议学 nginx rewrite 模块之前 先把它看懂
正则表达式
http://www.apelearn.com/bbs/thread-11418-1-1.html
0
- if ($http_user_agent ~ MSIE) {
- : rewrite ^(.*)$ /msie/$1 break;
- }
- if ($http_cookie ~* "id=([^;] +)(?:;|$)" ) {
- : set $id $1;
- }
- if ($request_method = POST ) {
- : return 405;
- }
- if (!-f $request_filename) {
- : break;
- : proxy_pass http://127.0.0.1;
- }
- if ($slow) {
- : limit_rate 10k;
- }
- if ($invalid_referer) {
- : return 403;
- }
0
本帖最后由 乐橙306 于 2016-5-10 09:52 编辑
估计是你写成死循环了 你把你写的rewrite 内容复制 贴出来 我看看 =。=
正则表达式这部分看完没?
chao901103 发表于 2016-5-10 09:36
一个 虚拟主机 配置文件中可以写多个if rewrite 吗?
为什么我写完 访问网站 会出现提示 你多次重定向 打 ...
估计是你写成死循环了 你把你写的rewrite 内容复制 贴出来 我看看 =。=
正则表达式这部分看完没?
0
我是这么写的
[root@niaoyun-6 vhosts]# cat 80port.conf
server
{
listen 80;
server_name www.sundong.wang www.sundong.xyz;
index index.html index.htm index.php;
root /opt/nginx/html;
if ($host != 'www.sundong.wang' ) {
rewrite ^/(.*)$ http://www.sundong.wang/$1 permanent;
}
}
[root@niaoyun-6 vhosts]#
chao901103 发表于 2016-5-10 09:36
一个 虚拟主机 配置文件中可以写多个if rewrite 吗?
为什么我写完 访问网站 会出现提示 你多次重定向 打 ...
我是这么写的
[root@niaoyun-6 vhosts]# cat 80port.conf
server
{
listen 80;
server_name www.sundong.wang www.sundong.xyz;
index index.html index.htm index.php;
root /opt/nginx/html;
if ($host != 'www.sundong.wang' ) {
rewrite ^/(.*)$ http://www.sundong.wang/$1 permanent;
}
}
[root@niaoyun-6 vhosts]#
- [root@niaoyun-6 vhosts]# curl -I www.sundong.xyz
- HTTP/1.1 301 Moved Permanently
- Server: nginx
- Date: Tue, 10 May 2016 02:06:59 GMT
- Content-Type: text/html
- Content-Length: 178
- Connection: keep-alive
- Location: http://www.sundong.wang/
- [root@niaoyun-6 vhosts]# curl -v --head www.sundong.xyz
- * About to connect() to www.sundong.xyz port 80
- * Trying 118.192.147.6... connected
- * Connected to www.sundong.xyz (118.192.147.6) port 80
- > HEAD / HTTP/1.1
- > User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
- > Host: www.sundong.xyz
- > Accept: */*
- >
- < HTTP/1.1 301 Moved Permanently
- HTTP/1.1 301 Moved Permanently
- < Server: nginx
- Server: nginx
- < Date: Tue, 10 May 2016 02:07:02 GMT
- Date: Tue, 10 May 2016 02:07:02 GMT
- < Content-Type: text/html
- Content-Type: text/html
- < Content-Length: 178
- Content-Length: 178
- < Connection: keep-alive
- Connection: keep-alive
- < Location: http://www.sundong.wang/
- Location: http://www.sundong.wang/
- * Connection #0 to host www.sundong.xyz left intact
- * Closing connection #0
- [root@niaoyun-6 vhosts]#
0
你这学习http 入魔的节奏啊 发请求前 需要提前建立连接 完成三次握手吗 =。= {:4_118:}
chao901103 发表于 2016-5-10 18:37
解决了,后续还会用到,到时候 要请求你了!
你这学习http 入魔的节奏啊 发请求前 需要提前建立连接 完成三次握手吗 =。= {:4_118:}
编辑回复