Jump to content

.htacess Allow From X.x.x.x Problem


usr8481

Recommended Posts

order deny,allow 
deny from all 
allow from x.x.x.x (my ip)

 

 

Why this code in .htacess doesn't work properly?

It supposed to deny access for any ip but allow from specific.

But it deny access for my ip too.

 

I just want use next code

 

<files wp-login.php>
order deny,allow
deny from all
</files>

Link to comment
Share on other sites

Make sure you've spelled .htaccess correctly.

With .htaccess everyhing is normal and I tested it on another hosting.

 

# BEGIN W3TC Browser Cache
<IfModule mod_mime.c>
.........................(wordpress cache plugin's settings)
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
.........................(wordpress settings)
</IfModule>
# END WordPress
order deny,allow
deny from all
allow from 99.99.99.99 (for e.g. my ip)

 

And of course I typed ip correctly, but I still doesn't have access if I use it

 

order deny,allow
deny from all
allow from 99.99.99.99 (for e.g. my ip)

 

or access to wp-admin (wp-login.php):

 

<Files wp-login.php>
order deny,allow
deny from all
allow from 99.99.99.99
</Files>

Link to comment
Share on other sites

When I uncomment this part out in your .htaccess file:

 

<Files wp-login.php>
order deny,allow
deny from all
allow from xxxxxxxxx
</Files>

 

And try going to your wp-login.php page, I get a redirect loop. It seems like you might have some errors in your .htaccess file. Try adding just the code above to your .htaccess file and see if it works then.

Link to comment
Share on other sites

You could try putting this code at the top of your .htaccess file and maybe it would deliver the page before any errors were caught in the remaining .htaccess:

 

<Files wp-login.php>
order deny,allow
deny from all
allow from xxxxxxxxx
</Files>

Link to comment
Share on other sites

  • 5 months later...

I also use Cloudflare and when it's enabled rules from .htaceess don't work correctly or just don't work

 

for e.g.

I have in my .htaccess code to block specific country:

<Limit GET HEAD POST>
order allow,deny
allow from all
deny from 1.11.0.0/16
deny from 1.16.0.0/14
...
</Limit>

 

it works okay when Clouldflare is paused (I test with proxy for the country I blocked), but it doesn't work when Cloudflare is enabled.

 

But that behaviour is different for other hostings - it works ok with Clouldflare enabled and disabled (paused).

 

Do you have any idea why there are such problems when Cloudlfare is enabled?

 

sorry for my English

Link to comment
Share on other sites

When cloudflare is enabled, the visitor connects trough cloudflare to the server and the server doesn't see the visitor's ip. Cloudflare added the headerCF-Connecting-IP including the real ip.

http://www.simplemachines.org/community/index.php?topic=524146.0

Strange that it works with other hosters, maybe they are able to detect when someone connects via Cloudflare and then they select the IP transmitted in CF-Connecting-IP for such proposes....

Link to comment
Share on other sites

I tried this (from http://www.asiteaboutnothing.net/c_block-countries.html) and it works ok

SetEnvIf CF-IPCountry CountryCode BuzzOff=1
Order allow,deny
Allow from all
Deny from env=BuzzOff

 

thanks

 

does it use IPs from cloudflare database?

 

Strange that it works with other hosters

 

first my method (<Limit GET HEAD POST>...) I decided to try because of cloudflare infromation on https://support.cloudflare.com/hc/en-us/articles/200171406-How-do-I-block-connections-based-on-country-or-countries-

 

If you fully want to block visitors from that country, then you would have to put rules on your server to block the country - http://www.ip2location.com/free/visitor-blocker
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...