Answer the question
In order to leave comments, you need to log in
How to redirect all but a few IPs in .htaccess?
The Internet is full of the opposite - redirect everyone, redirect to known IPs, etc.
And I need the following:
-if IP (or subnet, not important) is X or Y, then give index.php
-give index.html to everyone else or redirect to the directory / sorry/ (whichever is easier to implement).
Answer the question
In order to leave comments, you need to log in
Che, for two years they did not give the right answer ???
Here:
RewriteCond %{REMOTE_ADDR} !93.143.174.0
RewriteRule ^index.php$ index.html [L,QSA]
!^(93\.143\.174\.0|127\.111\.11\.111)
tried but didn't work:
RewriteCond %{REMOTE_ADDR} !^93.143.174.*
RewriteRule ^(.*)$ index.html [R,L]
RewriteCond %{REMOTE_ADDR} !^(127).0.0.[0-9]+
RewriteRule ^(.*)$ index.html [L]
# это регэксп, так что подсеть можно только /24 /16 или перечислением
RewriteCond %{REMOTE_ADDR} ^192\.168\.(1|2|3|4)\.
RewriteRule . /index.php [S=1]
# тут делаем то что нужно для всех остальных
RewriteRule . /index.html
Using the Skip flag, you can build any conditional constructions, while in the rule itself we divide the condition for the incoming url, and if you need something outside the url, such as an address, add the conditions above
sorry tag mixed up
# это регэксп, так что подсеть можно только /24 /16 или перечислением
RewriteCond %{REMOTE_ADDR} ^192\.168\.(1|2|3|4)\.
RewriteRule . /index.php [S=1]
# тут делаем то что нужно для всех остальных
RewriteRule . /index.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question