htaccess to restrict access to single WP page by IP
-
Hi,
I need to restrict a single page in WordPress by user IP and I understand that htaccess is the way to do this. Private or Password Page visibility in WP is not suitable in this particular case. Basically I need seamless access to this page for users in my office, but block everyone else. The rest of the website is public.
I can block all of wp-login or wp-admin (there are are lots of example of this), but can’t find the right syntax for a single “normal” page in WP. (All examples I can find are for static html pages, but in WP this doesn’t work)
Here’s what I’m trying (example is for page https://myurl/secret/ restricted to two IPs)
# BEGIN Whitelist for secret page RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} ^(.*)?secret\.php(.*)$ RewriteCond %{REMOTE_ADDR} !^86\.26\.215\.164$ RewriteCond %{REMOTE_ADDR} !^81\.187\.29\.134$ RewriteRule ^(.*)$ - [R=403,L] # END Whitelist for secret page
This is based on examples I found, but I will freely admit that I don’t understand all the switches etc..
I’d be grateful for any help specifically on how to address a single WP page, which as I understand it is not a “file” in this context (unlike a static html page).
Many thanks,
Paul
- The topic ‘htaccess to restrict access to single WP page by IP’ is closed to new replies.