Subdomains to pages

The question:

Hi I have a website on wordpress which have 2 pages which I meant to convert it to subdomain.

Eg: Let my website at be

there are two pages and

I want them to be accessible at & respectively.

Also I have may subpages to page1 which i wanna access using subdomain of main page. I mean if is subpage of then I want to access it as

I have already created subdomains in cpanel pointing them to root folder of my website and tried following htaccess.

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{REQUEST_URI} !^/subsite [NC]
RewriteRule ^(.*)$ /subsite/$1 [L]

I have tried different other variants of htaccess code I got from different forums and also

Also tried WP Subdomains (Revisited) plugin and found of no use.

Please help me to fix it.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

It’s better to use WP_Rewrite for that.

function my_page_rules($rules){
$pageslug = 'sample-page';
$rules['([^/]+)/?$'] = 'index.php?pagename='$pageslug'/$matches[1]';
return $rules;
add_filter( 'page_link', 'sub_page_link');
function sub_page_link(){
// preg_replace here

I have found a premium plugin which uses the same mechanism to convert pages into subdomain, it uses rewrite rules and Server WildCard Configured.

Hope it is helpful!

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment