I have just put a website live, but I need to restrict access to everything except the homepage for users outside of my IP address.

I would like to do this using .htaccess.

So far I have come up with this but it doesn't work:

Order Deny,Allow
Deny from all
Allow from

<Files /index.php>
    Order Allow,Deny
    Allow from all

The file that I want to make viewable to the world is located here:


The .htacess file is located here:


Wordpress re-writes everything to /index.php which complicates matters.

Any ideas?

  • "Allow from all" should provide a hint. – Giovanni Tirloni Sep 26 '14 at 11:44

First, your solution probably won't do what you want, because you haven't allowed for image, CSS, or Javascript files.

Since as you say Wordpress rewrites everything to /index.php, it seems that your choices are either to intercept that rewriting before it takes place, or find a way to work within Wordpress to restrict access. The second choice seems more likely to succeed. I see there's a plugin that claims to do it, and it has a FAQ on how to restrict access to just part of the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.