简体   繁体   English

如何设置wordpress(Windows托管)页面/部分以使用子域?

[英]How can I set a wordpress(windows hosting) page/section to use a subdomain?

I have been researching through the web a lot and found nothing that fits to my specific situation.(Actually, nothing that works so far). 我已经在网络上进行了很多研究,但没有找到适合我的具体情况的文件(实际上,到目前为止还没有任何结果)。 Let's say I have a wordpress site on domain.com. 假设我在domain.com上有一个wordpress网站。 I have a section/page I am going to call testpage. 我有一个部分/页面,我将其称为测试页。 I need it set to use testpage.domain.com. 我需要将其设置为使用testpage.domain.com。 As title says, this is a windows hosting. 如标题所示,这是Windows托管。 I tried following: 1) I added the following rule to web.config: 我尝试了以下操作: 1)我在web.config中添加了以下规则:

<rule name="Rewrite sub-domain to dir" enabled="true">
    <match url="^(.*)$" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^testpage\.domain\.co\.uk$" />
    </conditions>
    <action type="Rewrite" url="testpage/{R:1}" />
</rule>

2) I Created the subdomain and set it to /testpage Then in testpage I put index.php with the following code: 2)我创建了子域并将其设置为/ testpage,然后在testpage中,使用以下代码放置了index.php:

<?php
/**
* Front to the WordPress application. This file doesn’t do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/

/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/

$_GET[‘page_id’]=4323;

define(‘WP_USE_THEMES’, true);

/** Loads the WordPress Environment and Template */
require(‘../wp-blog-header.php’);

I took the id from wordpress. 我从wordpress取得ID。

I am not a coder and while I kinda understand a bit of code in both cases, I am far from an expert and I can't say for sure there are no errors there. 我不是编码人员,虽然我在这两种情况下都可以理解一些代码,但我距离专家还很远,我不能肯定地说那里没有错误。 But thing is none of those methods worked for me. 但是这些方法都不适合我。 Method 1 will load testpage.domain.com/testpage, instead of just testpage.domain.com Method 2 will kinda work but just loads the home, instead of the page whose ID I put in the code. 方法1将加载testpage.domain.com/testpage,而不只是testpage.domain.com 方法2将可以工作,但仅加载主页,而不是我在代码中放入其ID的页面。

I thank a lot in advance to anyone who takes a look at this. 我非常感谢任何对此感兴趣的人。

我的朋友,我建议您切换到Linux托管,您可以在其中进行适当的重定向。

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

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