WordPress 初始页面带有 htaccess?

发布于 2024-12-08 09:40:02 字数 151 浏览 1 评论 0原文

我在根目录中设置了一个 WordPress 网站。我需要设置一个临时启动页面来宣传带有“输入”按钮的专辑,该按钮将引导至常规网站。我知道有一种方法可以通过将文件移动到不同的目录来做到这一点,但我不想这样做。有没有更简单的方法可以使用 htaccess 来做到这一点?或者其他更简单的方法?

I have a WordPress site set up in the root. I need to set up a temporary splash page to promote an album with an 'enter' button which will lead to the regular site. I know there is a way to do this by moving files to different directories but I'd rather not do that. Is there a simpler way to do this perhaps with htaccess? Or another simpler method?

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

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

发布评论

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

评论(3

肩上的翅膀 2024-12-15 09:40:02

很简单。

在您的 htaccess 文件中添加 DirectoryIndex flash.php blog.php

在根目录中添加 splash.php 文件。在此文件中添加启动页面代码。

复制 index.php 文件并将新文件重命名为 blog.php

登录 wp-admin,转到 setting ->;常规设置

更改站点地址(URL)值,应该是http://www.yoursite.com/blog.php

就这样!!!!

Quite simple.

add DirectoryIndex splash.php blog.php in your htaccess file.

add splash.php file in your root directory. add splash page code in this file.

copy index.php file and rename new file with name blog.php

Login in wp-admin, Go to setting -> General Settings

Change Site address (URL) value, it should be http://www.yoursite.com/blog.php

That's it!!!!

许仙没带伞 2024-12-15 09:40:02

您可以执行此操作的另一种方法是检测 HTTP_REFERER 并向您的 index.php 添加条件语句。这样,客户端计算机只会在输入根 URL 时看到启动画面(而不是通过刷新或单击主页)。

示例代码

<?php $referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/yoursite.com/",$referrer)) {
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
} else {
    header('Location: http://yoursite.com/splash.html');
}; ?>

确保您的 WordPress 注释块位于页面顶部。
不需要 .htaccess 周。

Another way you can do this is to detect the HTTP_REFERER and add a conditional statement to your index.php. This way client machines will only see the splash when entering in the root url (not by refreshing or clicking home).

Sample code

<?php $referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/yoursite.com/",$referrer)) {
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
} else {
    header('Location: http://yoursite.com/splash.html');
}; ?>

Make sure you have the wordpress comment block on the top of the page.
No .htaccess tweeks needed.

久而酒知 2024-12-15 09:40:02

我是这样使用的,到目前为止效果很好。从我的index.php中删除了其他内容(不是从主题中而是从wordpress本身)并将其留在这里:

<?php $referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/great2gether.com/",$referrer) ) {
    define('WP_USE_THEMES', true);
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
} else {
    header('Location: http://great2gether.com/splash.html');
}; 
?>


<?php

当然,您必须根据自己的URL更改域,并且需要在您的顶级wordpress中有一个splash.html文件文件夹。

希望这对某人有帮助:)

I used it like this and it works good, so far. Deleted the other stuff from my index.php (not from the theme but from wordpress itself) and left this here:

<?php $referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/great2gether.com/",$referrer) ) {
    define('WP_USE_THEMES', true);
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
} else {
    header('Location: http://great2gether.com/splash.html');
}; 
?>


<?php

Of course you will have to change the domain against your own URL and need to have a splash.html file in your top wordpress folder.

Hope this helps somebody :)

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