【问题标题】:Wordpress redirect all except my IPWordpress 重定向除我的 IP 之外的所有内容
【发布时间】:2014-10-26 14:20:27
【问题描述】:

我有两个带有永久链接的 wordpress 网站 NEWOLD。旧网站位于http://website.com/old,新网站位于http://website.com

我想使用 .htaccess 将我的所有 IP 重定向到旧网站 (http://website.com/old)。

位于主目录 (http://website.com) 的默认 .htaccess 是:

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

我已将其更改为以下内容(其中 xx.xxx.x.xxx 是我的 IP):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^xx.xxx.x.xxx
RewriteRule .* http://website.com/old [R=302,L]
</IfModule>

此时我可以将所有内容重定向到除我的 IP 之外的旧网站。问题是当我导航到我的新网站上的任何页面时,例如 http://website.com/contacts 它会返回:

Not Found
The requested URL /contacts/ was not found on this server.
Apache Server at website.com Port 80

有什么想法吗?谢谢

【问题讨论】:

    标签: wordpress .htaccess redirect ip permalinks


    【解决方案1】:

    您必须您的 IP 检查后保留 Wordpress 的主要规则

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    # if not my ip then redirect to old version
    RewriteCond %{REMOTE_HOST} !^xx\.xxx\.x\.xxx$
    RewriteRule . old [R=302,L]
    
    # if we're here, it means it's me so display new version
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 2017-02-18
      • 2012-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-05
      • 1970-01-01
      • 2021-05-01
      • 2010-10-07
      相关资源
      最近更新 更多