S
S
StrangeAttractor2014-02-19 05:33:57
Apache HTTP Server
StrangeAttractor, 2014-02-19 05:33:57

How to write .htaccess rewrite rule based on client IP?

The task is quite natural: to block access to the site (a special domain allocated to developers for testing purposes) to everyone except for a certain IP. It would seem, what could be easier?

order deny,allow
deny from all
allow from allowed.ip.address

But I want to make it a little more beautiful, namely, not just give the left-handed visitors a thrashing, but show them a specially designed page with the project logo and a description of the situation. Those. in principle, this is allow plus one rewrite for just one specific. For any IP, its own set of rewrite rules must operate.
Tell?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Meketyuk, 2014-02-19
@StrangeAttractor

To redirect all those who are not destined to get to the site, then:
Give access to files to someone who is lucky enough to visit the site:

<FilesMatch "^(file1|file2)\.html$">
    allow from allowed.ip.address
</FilesMatch>

Source

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question