Режим поддержки 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 Beginner
Есть ли проблема с изменением названия index.php
в верхнем каталоге _index.php
и переименование моего maintenance.html
подать в index.php
?
3 ответа
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]
Это образец из того, что я использовал, изначально из No Creativity, но по какой-то причине не сработало.
Другой способ сделать это с помощью временной функции в вашем 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' ) )...
Мы используем это все время - без плагинов, без записей в базе данных, и очень быстро и легко внедрить и удалить.
Уважаемый Майк, почему вы изменяете свой файл доступа HTTP, просто перейдите и загрузите "WP Maintenance Mode" http://wordpress.org/plugins/wp-maintenance-mode/screenshots/
Как использовать этот плагин:
Сначала установите этот плагин на свой сайт WP. После установки активируйте этот плагин. Теперь нажмите на настройку и затем установите "true" вместо "false", и вы увидите, что ваш сайт автоматически запускается в режиме обслуживания. Вы также можете изменить стиль страницы обслуживания из CSS Style в плагине WP Maintenance.
Если вам нужна другая помощь, я всегда здесь, чтобы помочь вам