WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a blog on wordpress say example.com with a page name "mypage" in it. When a user clicks on mypage I want him to redirect to mypage.example.com (a subdomain that I have already created) inspite of opening example.com/mypage. I want my page to redirect to my subdomain.
I am a user of wordpress and hence I dont know much about how to do it. Please help me out on it, I would be really thankfull.

share|improve this question
up vote 2 down vote accepted

Can you use a custom menu (Appearance -> Menus) ? If so, just create a custom link and insert it where desired. This has the added benefit of not cluttering your list of pages with a page that isn't real.

share|improve this answer
Exactly what I wanted. Thnx... Accepting the answer. You told it in a UI way which matters a lot as I dont know much about wordpress coding. – amod0017 Nov 1 '12 at 6:26

I would say you have two options :

1/ You could use a Plugin like Yoast SEO, which is useful to SEO and allow you to define a 301 redirection to any page (just install the plugin, go to the page you need to redirect, and in the SEO options, in Advanced, you will find a redirect field where you could enter the URL where you want to redirect

or 2/ Create new file redirect.php with this code that you place in your theme folder via FTP :

* Template Name: Redirect

wp_redirect( 'mypage.example.com', 301 );


Then change the template of your example page to this Redirect template, which will redirect to the subdomain with a 301 redirection.

* EDIT * This is a wrong answer. You cannot use wp_redirect() because http headers are already processed at this point. I used successfully this code that rely on Javascript to redirect the page (not a perfect solution if JS is desactivated, of course).

<?php get_header(); ?>

<script type="text/javascript">
  window.location= <?php echo "'" . home_url() . "'"; ?>;

<?php get_footer(); ?>`
share|improve this answer
thnx Simon let me just try it buddy... :) – amod0017 Oct 31 '12 at 18:49
hi Simon... using the Yoast Plugin is great option but its redirecting it to "example.com/mypage/subdomain.com" I am sure I am entering something wrong. Any pointer on this? – amod0017 Oct 31 '12 at 19:02
Mike's solution is best solution. For Yoast Plugin, you need to enter full URL like http://example.domain.com – Simon Nov 1 '12 at 9:59
Thnx Simon for your valuable comment. I learned a new thing... :) – amod0017 Nov 1 '12 at 16:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.