简体   繁体   English

.htaccess更改后,所有页面都重定向到主页

[英]All pages redirect to homepage after .htaccess changes

I have a Wordpress site that I'm trying to test live, so I've changed my .htaccess file to redirect all pages to a maintenance page for everyone except me (based on my IP). 我有一个Wordpress网站正在尝试实时测试,因此我更改了.htaccess文件,将所有页面重定向到除我以外的所有人的维护页面(基于IP)。 Here are my rewrite rules: 这是我的重写规则:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ /maintenance.html [R=307,L]

</IfModule>

This works as intended: everyone sees the maintenance page except me. 这可以按预期工作:除我之外,每个人都可以看到维护页面。 The problem is only the homepage is working for me: every other link results in a 404 error. 问题是只有主页对我有用:每个其他链接都导致404错误。 What should I do to see the whole site working? 我应该怎么做才能看到整个站点正常工作?

By the way, the site is hosted on a Dreamhost VPS server that uses Ubuntu. 顺便说一下,该站点托管在使用Ubuntu的Dreamhost VPS服务器上。

Changing the rules as follows fixed it for me: 如下更改规则对我来说是固定的:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^151\.42\.160\.116
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ /maintenance.html [R=307,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

I guess once you've redirected everyone else to the maintenance page, you still need more rewrite rules so that the site can function properly for you. 我猜一旦将其他所有人重定向到维护页面后,您仍然需要更多的重写规则,以便站点可以为您正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM