Wordpress.htaccess维护模式不工作

Wordpress.htaccess维护模式不工作,wordpress,.htaccess,maintenance-mode,Wordpress,.htaccess,Maintenance Mode,我试图只显示一个即将到来或维护页面,除了选择IP的所有人。 我现在已经尝试了几种解决方案,并且已经确定了这个代码 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REMOTE_ADDR} !^xx\.xx\.xx\.xx RewriteCond %{REQUEST_URI} !/coming-soon\.html$ RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js|

我试图只显示一个即将到来或维护页面,除了选择IP的所有人。 我现在已经尝试了几种解决方案,并且已经确定了这个代码

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^xx\.xx\.xx\.xx
RewriteCond %{REQUEST_URI} !/coming-soon\.html$
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js|woff) [NC]
RewriteRule .* /coming-soon.html [R=302,L]
</IfModule>

重新启动发动机
重写cond%{REMOTE_ADDR}^xx\.xx\.xx\.xx
重写cond%{REQUEST_URI}/即将推出\.html$
重写条件%{REQUEST\u URI}!\。(jpe?g?| png | gif | css | js | woff)[NC]
重写规则。*/coming-soon.html[R=302,L]
无论何时有人进入主页,这都非常有效。但是,如果您转到任何其他页面,例如/contact、/shop等,它不会重定向

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我已将此代码放在页面底部。当我试图将其移动到页面顶部时,我收到一个错误,指出许多重定向。下面是我的标准Wordpress重定向

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
如何将所有页面限制为除所选ip之外的所有页面

谢谢

编辑 我在一台新服务器上进行了测试,没有缓存插件或向htaccess添加代码的安全插件,但仍然存在同样的问题。对主页的请求会被重定向,但对任何其他页面的请求不会被重定向。 下面是我的htaccess文件中的代码

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# BEGIN Trusted Access
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^xx\.xx\.xxx\.x
RewriteCond %{REQUEST_URI} !/coming-soon\.html$
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css|js|woff) [NC]
RewriteRule ^(.*)$ /coming-soon.html [R=302,L]
</IfModule>
# END Trusted Access
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
#开始受信任访问
重新启动发动机
重写cond%{REMOTE_ADDR}^xx\.xx\.xxx\.x
重写cond%{REQUEST_URI}/即将推出\.html$
重写条件%{REQUEST\u URI}!\。(jpe?g?| png | gif | css | js | woff)[NC]
重写规则^(.*)$/coming-soon.html[R=302,L]
#结束可信访问
方法#1:显示维护页面的自定义代码

如果您想在不使用维护模式插件的情况下在站点上显示基本维护启动页,可以将这段代码添加到functions.php中

function wp_maintenance_mode() {
   if (!current_user_can('edit_themes') || !is_user_logged_in()) {
     wp_die('<h1>Under Maintenance</h1><br />Something ain't right, but we're working on it! Check back later.');
   }
}
add_action('get_header', 'wp_maintenance_mode');
方法#3:使用WordPress维护模式插件

方法#1:自定义代码显示维护页面

如果您想在不使用维护模式插件的情况下在站点上显示基本维护启动页,可以将这段代码添加到functions.php中

function wp_maintenance_mode() {
   if (!current_user_can('edit_themes') || !is_user_logged_in()) {
     wp_die('<h1>Under Maintenance</h1><br />Something ain't right, but we're working on it! Check back later.');
   }
}
add_action('get_header', 'wp_maintenance_mode');

方法3:使用WordPress维护模式插件

我尝试了一些基于这个问题的解决方案 为维护模式(例如wp维护模式)使用任何插件的最佳方式

或者试试这个

  • 您必须在根目录中创建一个maintenance.html文件,其中包含要向用户显示的任何消息
  • 您还可以在RewriteCond%{REMOTE_ADDR}中设置ip以设置允许的ip地址
维护页面重定向

重新启动发动机
重写cond%{REMOTE_ADDR}^192\.168\.0\.62
重写cond%{REQUEST_URI}!http://192.168.0.254/html/woocommerce-task/maintenance.html$[NC]
重写条件%{REQUEST\u URI}!\。(jpe?g?| png | gif)[NC]
重写规则。*http://192.168.0.254/html/woocommerce-task/maintenance.html [R=302,L]
  • 如果只想允许一些ip

命令拒绝,允许
全盘否定
允许从192.168.0.254开始
注意:-使用您希望允许的ip地址更改ip地址,并记住使用静态ip进行开发。因此,您可以很容易地限制对该站点的访问。

你好,保罗

我尝试了一些基于这个问题的解决方案 为维护模式(例如wp维护模式)使用任何插件的最佳方式

或者试试这个

  • 您必须在根目录中创建一个maintenance.html文件,其中包含要向用户显示的任何消息
  • 您还可以在RewriteCond%{REMOTE_ADDR}中设置ip以设置允许的ip地址
维护页面重定向

重新启动发动机
重写cond%{REMOTE_ADDR}^192\.168\.0\.62
重写cond%{REQUEST_URI}!http://192.168.0.254/html/woocommerce-task/maintenance.html$[NC]
重写条件%{REQUEST\u URI}!\。(jpe?g?| png | gif)[NC]
重写规则。*http://192.168.0.254/html/woocommerce-task/maintenance.html [R=302,L]
  • 如果只想允许一些ip

命令拒绝,允许
全盘否定
允许从192.168.0.254开始
注意:-使用您希望允许的ip地址更改ip地址,并记住使用静态ip进行开发。因此,您可以很容易地限制对该站点的访问。

谢谢,但我已经尝试了您的htaccess规则,但没有成功。你在Wordpress上试过这个吗?另外,虽然
在按ip过滤中工作,但它提供403页。并在wp-cron.php尝试运行时抛出错误。我肯定在本地设置中尝试过。我也尝试过局域网系统IP,它对我很有效。这个问题真的困扰着我,所以我只是想澄清一下。当您请求主页以外的页面时,您的系统是否成功重定向?希望我能看到这一切,因为这对我来说根本不起作用。就像@GovindSoni一样。我可以得到你用来测试这个的堆栈吗?谢谢谢谢,但我已经尝试了你的htaccess规则,但没有成功。你在Wordpress上试过这个吗?另外,虽然
在按ip过滤中工作,但它提供403页。并在wp-cron.php尝试运行时抛出错误。我肯定在本地设置中尝试过。我也尝试过局域网系统IP,它对我很有效。这个问题真的困扰着我,所以我只是想澄清一下。当您请求主页以外的页面时,您的系统是否成功重定向?希望我能看到这一切,因为这对我来说根本不起作用。就像@GovindSoni一样。我可以得到你用来测试这个的堆栈吗?谢谢你的回答。我需要允许某些ip。我不知道这将如何与添加操作一起工作。我也试过你的htaccess代码,当你输入一个页面(例如my.website.com/shop)时,它不会重定向。你在世界上试过这个吗
<Limit GET POST>
    Order Deny,Allow
    Deny from all
    Allow from 192.168.0.254
</Limit>

Note:- Change the ip address with ones that you want to allow and remember to use static ip for development. so it will be easy for you to restrict access for the site.