admin管理员组

文章数量:1389779

I'm currently working on a production site where htaccess is blocking users that do not have my IP from accessing the site:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^11.22.33.44
RewriteCond %{REQUEST_URI} !^/brb/(.)*$ [NC]
RewriteRule ^(.*)$ /brb/index.html [R=307,L]

Maintenance mode, basically.

I've now realized, WP Crons are not running. And I'm trying to force them to run (WP Cron Control plugin) by selecting "run now". They're all stuck at "Running: (now)" but never execute.

I assume it has something to do with the htaccess, but do not know how to make an exception for wp-crons without allowing in all public traffic for a moment?

I'm currently working on a production site where htaccess is blocking users that do not have my IP from accessing the site:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^11.22.33.44
RewriteCond %{REQUEST_URI} !^/brb/(.)*$ [NC]
RewriteRule ^(.*)$ /brb/index.html [R=307,L]

Maintenance mode, basically.

I've now realized, WP Crons are not running. And I'm trying to force them to run (WP Cron Control plugin) by selecting "run now". They're all stuck at "Running: (now)" but never execute.

I assume it has something to do with the htaccess, but do not know how to make an exception for wp-crons without allowing in all public traffic for a moment?

Share Improve this question asked Apr 10, 2020 at 21:37 yesbutmaybenoyesbutmaybeno 1655 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

The .htaccess directives block any HTTP request not coming from your IP address. However, I believe WP Cron is also an HTTP request that originates from the server. So, you need to also make an exception for the server's external IP address.

These directives can also be simplified a bit...

For example:

RewriteCond %{REMOTE_ADDR} !=203.0.113.111
RewriteCond %{REMOTE_ADDR} !=11.22.33.44
RewriteRule !^brb/ /brb/index.html [R=307,L]

Where 203.0.113.111 is whatever your server's IP address is.

The = operator on the CondPattern makes it a lexicographical string comparison, as opposed to a regex, so no need for the start-of-string anchor (^) or escaping of literal dots (which you aren't doing anyway, but strictly should be).

No need for the additional condition that checks that the URL-path does not start /brb/, since this can be incorporated into the RewriteRule pattern. (And no need for the capturing groups, since you don't have any backreferences.)

本文标签: Temporary htaccess blocking is disabling WP Crons from running