WordPress 的 .htaccess 仅重定向问题

发布于 2024-10-04 11:13:03 字数 777 浏览 0 评论 0原文

我正在开发一个人们已经知道其 URL 的网站。当然,我不希望他们看到它正在进行中,因此我编写了一个 .htaccess 规则,将所有访问 www.example.com 的流量重定向到 /temp/index.html,这是一个正在建设的页面。

我现在想做的是向客户提供某种链接,该链接将链接到 WordPress 主页。不幸的是,WordPress 已经制定了 .htaccess 规则来重写所有内容以不包含 index.php。因此,每当我点击页面上的“主页”链接时,它都会进入正在建设的页面,我永远无法看到主页。

这是当前 .htaccess 中的代码,包括我的重定向:

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

# END WordPress
RewriteEngine on
RewriteCond %{HTTP_HOST} ^journeyfx\.com$
RewriteRule (.*) http://www.journeyfx.com/$1 [R=301,L]
RewriteRule ^$ /temp/index.html [L]

知道如何在不将整个 WP 站点重新定位到新目录的情况下执行此操作吗?

I am working on a site which people already know the URL of. Naturally, I don't want them to see it in progress, so I wrote an .htaccess rule to redirect all traffic to www.example.com to /temp/index.html which is an under construction page.

What I want to do now is to have some sort of link that I can give to the client, that will link to the WordPress homepage. Unfortunately, WordPress already has .htaccess rules in place to rewrite everything to not include the index.php. Therefore, any time I click on the "Home" link on the page, it goes to the under construction page, and I am never able to see the homepage.

Here is the code that is in .htaccess currently, including my redirect:

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

# END WordPress
RewriteEngine on
RewriteCond %{HTTP_HOST} ^journeyfx\.com$
RewriteRule (.*) http://www.journeyfx.com/$1 [R=301,L]
RewriteRule ^$ /temp/index.html [L]

Any idea how to do this without relocating the whole WP site to a new directory?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

方圜几里 2024-10-11 11:13:03

好吧,你可以让它更简单,为你的客户创建一个新用户,然后告诉他从 yourwebsite.com/wp-login.php 登录,然后将其添加到你的 header.php (从第一行开始。)

<?php if(!is_user_logged_in()) { wp_redirect(get_bloginfo('url') . '/new-path.html'); } ?>

(如果用户是未登录它将被重定向到 yourwebsite.com/new-path.html)

Well, you can make it more simple, make a new user for your client then tell him to login from yourwebsite.com/wp-login.php then add this to your header.php (from the first line.)

<?php if(!is_user_logged_in()) { wp_redirect(get_bloginfo('url') . '/new-path.html'); } ?>

(if user is not logged in it will be redirected to yourwebsite.com/new-path.html)

岁月静好 2024-10-11 11:13:03

只需将index.html 文件放在与WordPress 的index.php 相同的目录中即可。由于 .html 通常在 DirectoryIndex 指令中列在较高位置,因此除非明确说明,否则它将优先并在 .php 文件之前加载。访问journeyfx.com的用户将看到“正在建设”页面,而如果您输入journeyfx.com/index.php,您将获得WP。

如果未按该顺序加载,您可能需要将以下内容添加到 .htaccess:

DirectoryIndex index.html index.php

Just put the index.html file in the same directory as WordPress' index.php. Because .html is usually listed higher in the DirectoryIndex directive, it will get precedence and load before the .php file unless explicitly stated. Users going to journeyfx.com will see the "Under Construction" page, while if you put journeyfx.com/index.php, you'll get WP.

If it doesn't load in that order, you may need to add the following to .htaccess:

DirectoryIndex index.html index.php
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文