简体   繁体   中英

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. I have a section/page I am going to call testpage. I need it set to use testpage.domain.com. As title says, this is a windows hosting. I tried following: 1) I added the following rule to 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:

<?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.

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.

I thank a lot in advance to anyone who takes a look at this.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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