1

我知道编写处理维护模式页面的 .htaccess 的基础知识。

我不想使用插件,因为我需要在维护模式下替换整个 WP 站点。

我尝试添加其他规则以允许访问 WP 后端,仅适用于特定 IP。

我已经尝试了几次尝试,最终非常接近我需要的东西。

但是,我也希望白名单 IP 能够看到前端站点,而不会被重定向到维护页面,但我被困在那里。

这是我当前的.htaccess:

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/images [OR]
RewriteCond %{REQUEST_URI} ^/wp-admin/.* [OR]
RewriteCond %{REQUEST_URI} ^/wp-content/.* [OR]
RewriteRule .+ - [L]

RewriteCond %{REMOTE_ADDR} !^93\.62\.93\.79
RewriteCond %{REQUEST_URI} !^/maintenance-mode\.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance-mode.html [R=302,L]

我应该添加/更改什么?

4

1 回答 1

0

你找到解决方案了吗?我没有用 WP 测试它,但这对我来说适用于另一个 CMS。

Options +FollowSymLinks

RewriteEngine On

# exclude file (otherwise infinity loop)
RewriteCond %{REQUEST_URI} !^/under-construction/maintenance\.php$
# exclude images and css
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif|css) [NC]
# If it's not your IP address
RewriteCond %{REMOTE_HOST} !^111\.222\.333\.444$
# Redirect /abc to example.com/abc.
RewriteRule ^(.*)$ http://www.domain.com/under-construction/maintenance.php [R=307,L]

也许它会帮助你。

于 2013-07-03T15:02:02.593 回答