Apache rewrite subnet ip range

前端 未结 2 2104
天命终不由人
天命终不由人 2021-02-09 00:40

Can someone please tell me how to put the following IP ranges (belongs to Cloudfront) in a mod_rewrite? I am looking to redirect the non-www requests for example.com to www.exam

2条回答
  •  别那么骄傲
    2021-02-09 01:12

    If you're using Apache HTTPD 2.4 or later, you can also use expressions to match REMOTE_ADDR against a CIDR mask directly, instead of converting these to regexps.

    The short form looks like this:

    RewriteCond expr "-R '192.168.1.0/24'"
    

    The following longer form is also available, but the documentation suggests it is less efficient:

    RewriteCond expr "%{REMOTE_ADDR} -ipmatch '192.168.1.0/24'"
    

提交回复
热议问题