htaccess的请求转发,如果内部IP [英] htaccess request forwarding if internal ip

查看:104
本文介绍了htaccess的请求转发,如果内部IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可能htaccess的指令,可以从index.php文件透明地转发请求index_internal.php如果请求是从内部IP范围来吗?

解决方案

  RewriteEngine叙述上

的RewriteCond%{REMOTE_ADDR} ^ 192 \ .168 \ .1 \。 [要么]
的RewriteCond%{REMOTE_ADDR} ^ 10 \ 0.15 \。
重写规则^指数\ .PHP $ index_internal.php [R,NC,QSA,L]
 

这样做的:

启动mod_rewrite的引擎(您可能已经)

如果(客户端的IP地址以192.168.1。[或]

客户端的IP地址以10.15。)

和页面名称为的index.php([N] OT [C]酶敏感),[R] edirect到index_internal.php,[Q] uery [S]特林[A] PPEND(即的index.php?富=酒吧变成 index_internal.php?富=酒吧),[L]屋檐处理。

根据需要对IP地址块

修改

Is there a possible htaccess directive that can transparently forward request from index.php to index_internal.php if the request is coming from an internal ip range?

解决方案

RewriteEngine on

RewriteCond %{REMOTE_ADDR} ^192\.168\.1\. [OR]
RewriteCond %{REMOTE_ADDR} ^10\.15\.
RewriteRule ^index\.php$ index_internal.php [R,NC,QSA,L]

What this does:

start mod_rewrite engine (you may have that already)

if (client IP address starts with "192.168.1." [or]

client IP address starts with "10.15.")

and page name is index.php ([n]ot [c]ase sensitive), [r]edirect to index_internal.php, [q]uery [s]tring [a]ppend (i.e. index.php?foo=bar becomes index_internal.php?foo=bar), [l]eave processing.

Modify as needed for IP address blocks.

这篇关于htaccess的请求转发,如果内部IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆