如何将子域映射到 WordPress 帖子?

发布于 2024-09-30 14:57:11 字数 285 浏览 0 评论 0原文

有点奇怪的问题,我希望我的 WordPress 博客使用子域作为永久链接,有点像流行的网站“设置”。

我已经将 Apache 配置为加载站点,无论子域如何,我只需要弄清楚如何让 Wordpress 加载正确的帖子。我将永久链接结构设置为“/%postname%/”,因为我将手动确保帖子名称是唯一的。

我需要解决的只是如何将子域映射到帖子名 - 我猜它需要 mod_rewrite?但我不确定如何继续。

谢谢

Slightly strange question, I want my Wordpress blog to use subdomains as permalinks, a bit like the popular website "The Setup".

I already have Apache configured to load the site irrespective of the subdomain, I just need to work out how to make Wordpress load the right post. I have my permalink structure set as "/%postname%/" as I will manually ensure the post names are unique.

All I need to work out is how to get the subdomains mapped to the postname - I'm guessing it requires mod_rewrite? But I'm unsure how to proceed.

Thanks

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

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

发布评论

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

评论(2

温柔女人霸气范 2024-10-07 14:57:11

我使用 nginx 进行设置,所以我不确定这是否会对您有很大帮助(我也不能保证这是最好的方法),但我的配置如下所示:

location = / {

        if ($host ~* "^([a-z0-9+\.\-]+)\.usesthis\.com$") {
            set $interview $1;
        }

        if ($interview !~* '^(www)?
) {
            rewrite ^(.*)$ /interviews/$interview.html;
        }
    }
}

I'm using nginx for The Setup, so I'm not sure if that will help you much at all (nor can I guarantee that this is the best way to do it) but my config looks something like this:

location = / {

        if ($host ~* "^([a-z0-9+\.\-]+)\.usesthis\.com$") {
            set $interview $1;
        }

        if ($interview !~* '^(www)?
) {
            rewrite ^(.*)$ /interviews/$interview.html;
        }
    }
}
憧憬巴黎街头的黎明 2024-10-07 14:57:11

使用 Wordpress 核心功能实现此目的的最佳方法似乎是“创建网络”功能 - 以前称为 Wordpress 多站点 (MU)。

您所要做的就是在 wp-config.php 文件中添加一行,以从 Wordpress 仪表板开始设置选项。

这里有详细信息: http://codex.wordpress.org/Create_A_Network

但是,请注意,此时就屏幕外观和工作流程而言,它们稍微过时了。 (例如,完成该过程后,现在不再从管理破折号栏中的左上角链接进入网络管理界面,该链接位于右上角,看起来有点不同)。

The best way to accomplish this with Wordpress core features seems to be the "Create a Network" feature - formerly Wordpress Multi-Site (MU).

All you have to do is add a line to your wp-config.php file to begin the setup options from the Wordpress dashboard.

There are details here: http://codex.wordpress.org/Create_A_Network

However, be advised that at this time they are slightly out of date in terms of what the screens look like, and the workflow. (For example, once you've gone through the process, now instead of entering the Network Admin interface from the top left link in the admin dash bar, the link is in the top right and looks a bit different).

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