|
例如:允许指定的域名访问本站,其他的域名一律转向www.linuxidc.net 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 ; }
?
常见nginx rewrite实例
1、php常见框架重定向,tag功能重定向
location / { ? root /app/html; ? rewrite ^/tag/([a-z0-9]+)/$ /index.php?m=tag&c=tag&id=$1 last; ? rewrite ^/(.*) /index.php?_ROUTE_=$1 last; ? index index.html index.php; } (编辑:网站开发网_安阳站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|