Режим обслуживания Wordpress .htaccess

Я пробовал несколько способов разместить страницу обслуживания, пока обновляю блог WordPress, но безрезультатно. Я получаю внутреннюю ошибку сервера.

RewriteEngine On

# Add all the IP addresses of people that are helping in development
# and need to be able to get past the maintenance mode.
# One might call this the 'allow people list'
RewriteCond %{REMOTE_HOST} !^83\.101\.79\.62
RewriteCond %{REMOTE_HOST} !^91\.181\.207\.191

# Make sure the <em>maintenance mode</em> only applies to this domain
# Example: I am hosting different sites on my server
# which could be affected by these rules.
RewriteCond %{HTTP_HOST} ^nocreativity.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.nocreativity.com$

# This is the 'ignore file list'. It allows access to all
# files that are needed to display the <em>maintenance mode</em> page.
# Example: pages, css files, js files, images, anything.
# IMPORTANT: If you don't do this properly, visitors will end up with
# endless redirect loops in their browser.
RewriteCond %{REQUEST_URI} !/offline\.htm$
RewriteCond %{REQUEST_URI} !/css\/style\.css$
RewriteCond %{REQUEST_URI} !/images\/logo\.png$

# Rewrite whatever request is coming in to the <em>maintenance mode</em> page
# The R=302 tells browsers (and search engines) that this
# redirect is only temporarily.
# L stops any other rules below this from executing whenever somebody is redirected.
RewriteRule \.*$ /offline.htm [R=302,L]

Приведенный выше код взят из Без творчества.

я тоже пробовала...

# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000
 RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
 RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
 RewriteRule .* /maintenance.html [R=302,L]
</IfModule>

... из Начинающий WP

Есть ли проблема просто изменить имя index.php в верхнем каталоге на _index.php и переименовать мой файл maintenance.html в index.php?


person Michael    schedule 08.04.2014    source источник
comment
Вы должны использовать htaccess? Есть плагины WordPress, которые также могут достичь этого.   -  person Howli    schedule 08.04.2014
comment
Теперь я разобрался, я не знаю, в чем проблема, может быть, это связано с комментариями в моем .htaccess. Плагины, на которые я смотрел, были неприятными и рекламировались повсюду.   -  person Michael    schedule 08.04.2014
comment
Я использовал wordpress.org/plugins/restricted-site-access, несколько раз, и я не видел никакой рекламы на нем. Вы можете настроить перенаправление на определенную страницу.   -  person Howli    schedule 08.04.2014


Ответы (3)


Другой способ сделать это — использовать временную функцию в файле functions.php:

function maintenance_redirect(){
    if( !is_user_logged_in() ){
        wp_redirect( site_url( 'maintenance.html' ), 302 );
        exit();
    }
}
add_action( 'init', 'maintenance_redirect' );

Это отправит всех не вошедших в систему пользователей на вашу страницу обслуживания, в то время как вы можете использовать WordPress как обычно, пока вы вошли в систему. Если у вас есть зарегистрированные пользователи на сайте, вы можете изменить оператор if просто на проверьте администраторов или даже просто проверьте одного конкретного пользователя.

if( !is_user_logged_in() || !current_user_can( 'manage_options' ) )...

Мы используем это все время - никаких плагинов, никаких записей в базе данных, и очень быстро и легко внедрить и удалить.

person I'm Joe Too    schedule 08.04.2014

RewriteEngine On

# Add all the IP addresses of people that are helping in development
# and need to be able to get past the maintenance mode.
# One might call this the 'allow people list'
RewriteCond %{REMOTE_HOST} !^111\.222\.333\.444

# Make sure the <em>maintenance mode</em> only applies to this domain
# Example: I am hosting different sites on my server
# which could be affected by these rules.
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$

# This is the 'ignore file list'. It allows access to all
# files that are needed to display the <em>maintenance mode</em> page.
# Example: pages, css files, js files, images, anything.
# IMPORTANT: If you don't do this properly, visitors will end up with
# endless redirect loops in their browser.
RewriteCond %{REQUEST_URI} !/maintenance\.html$
RewriteCond %{REQUEST_URI} !/somejavascriptfile\.js$
RewriteCond %{REQUEST_URI} !/css\/yourstylesheet\.css$
RewriteCond %{REQUEST_URI} !/img\/yourlogo\.jpg$

# Rewrite whatever request is coming in to the <em>maintenance mode</em> page
# The R=302 tells browsers (and search engines) that this
# redirect is only temporarily.
# L stops any other rules below this from executing whenever somebody is redirected.
RewriteRule \.*$ /maintenance.html [R=302,L]

Это образец того, что я использовал, первоначально из Нет Творчество, но почему-то не сработало.

person Michael    schedule 11.04.2014

Уважаемый Майк, почему вы изменяете свой файл доступа HTTP, просто скачайте «Режим обслуживания WP» http://wordpress.org/plugins/wp-maintenance-mode/screenshots/

Как использовать этот плагин:

Сначала установите этот плагин на свой сайт WP. После установки активируйте этот плагин. Теперь нажмите «Настройка», а затем установите «true» вместо «false», и вы увидите, что ваш сайт автоматически запускается в режиме обслуживания. Вы также можете изменить стиль страницы обслуживания из стиля CSS в плагине WP Maintenance. введите здесь описание изображения

Если вам нужна какая-либо другая помощь, я всегда здесь, чтобы помочь вам

person Muhammad Waseem    schedule 08.04.2014