Apache和Nginx规则的对应关系【附表】

今天爱分享给大家带来Apache和Nginx规则的对应关系【附表】,希望能够帮助到大家。

apache的规则 nginx的规则
RewriteCond 对应Nginx的if
RewriteRule 对应Nginx的rewrite
[R] 对应Nginx的redirect
[P] 对应Nginx的last
[R,L] 对应Nginx的redirect
[P,L] 对应Nginx的last
[PT,L] 对应Nginx的last

例如:允许指定的域名访问本站,其他的域名一律转向blog.itblood.com
Apache:

RewriteCond %{HTTP_HOST} !^(.*?)\.aaa\.com$[NC]
RewriteCond %{HTTP_HOST} !^localhost$ 
RewriteCond %{HTTP_HOST}!^192\.168\.0\.(.*?)$
RewriteRule ^/(.*)$ http://www.linuxidc.net[R,L]

Nginx:

if( $host ~* ^(.*)\.aaa\.com$ )
{
  set $allowHost '1';
}
if( $host ~* ^localhost )
{
  set $allowHost '1';
}
if( $host ~* ^192\.168\.1\.(.*?)$ )
{
  set $allowHost '1';
}
if( $allowHost !~ '1' )
{
  rewrite ^/(.*)$ http://www.linuxidc.netredirect ;
}
原文链接:https://blog.itblood.com/552.html,转载请注明出处。
0
【欧美SLG/汉化/完结】我的可爱表姐2v16.10260完结 AI版【PC+安卓/5.93G/更新】My Cute Roommate 2 [v16.10260 Extra]
【欧美SLG/汉化/完结】我的可爱表姐2v16.10260完结 AI版【PC+安卓/5.93G/更新】My Cute Roommate 2 [v16.10260 Extra]
10分钟前 有人购买 去瞅瞅看

站点公告

显示验证码
没有账号?注册  忘记密码?