WordPress.org

Ready to get started?Download WordPress

Forums

How do I make a page redirect to my static website? (25 posts)

  1. storm_law
    Member
    Posted 5 years ago #

    I would like a page link from my blog redirect to my static website. You know how you can create a page and the link will appear on the blog. I would like it to go directly to my static website.

  2. hersonrivera
    Member
    Posted 5 years ago #

    Just change the hyperlink source to your static website address

  3. ClaytonJames
    Member
    Posted 5 years ago #

    See if anything in this thread, or the links in it, are of any help:

    http://wordpress.org/support/topic/248486?replies=7

  4. Shane G
    Member
    Posted 5 years ago #

    Hi,

    You can write an redirection code in .htaccess file of your domain.

    Redirect /wordpress/index.php http://www.domain.com

    Thanks,

    Shane G.

  5. storm_law
    Member
    Posted 5 years ago #

    What I want to do is create a wordpress page that will in turn creat a link on the blog, but I want that link to go to my static website rather than the wordpress page.

    Any way to do this?

  6. ClaytonJames
    Member
    Posted 5 years ago #

    Any way to do this?

    Yes.

    The link I already posted for you above, leads you to more than one solution.

    What I want to do is create a wordpress page that will in turn creat a link on the blog, but I want that link to go to my static website rather than the wordpress page.

    Here is a solution that I have used successfully, but you should of course, choose whatever solution is best for you.

    1) Create a new empty page template. Name it whatever you want. For this example we'll call it mywebsite.php. Save your new blank template as mywebsite.php. It must have the .php extension.

    2)Open your new blank page template in a plain text editor. Inside of it, paste the following code:

    <?php
    /*
    Template Name: mywebsite
    */
    ?>
    <?php header('Location: http://www.mywebsite.com');
          die();
    ?>

    I am told that it is important not to leave any white space in front of the <?php.

    3) Now change the template name information to reflect the actual name of your new template, and change the url to reflect where you actually want it to take you when you click on the page.

    4) Upload your new page to to your current theme folder. Create a new page on your blog, name it whatever you like, and apply your new page template to the page and publish it.

    Now when you click on that page in your header navigation, it will take you to whatever url you put in the template. I'm sure there are several ways to do this. I know this way works because I've done it several times... just recently on WP 2.7.1. ...and the whole process takes about three minutes.

    Good luck to you.

  7. bwoosh
    Member
    Posted 5 years ago #

    thank you! this worked perfectly for me :)

  8. ClaytonJames
    Member
    Posted 5 years ago #

    You are most welcome. I'm glad to see someone other than myself has had success with it!

    :-)

  9. David Borrink
    Member
    Posted 5 years ago #

    Thanks, Clayton. I just found you solution and it's sooooo simple. I needed to redirect a tab to a shopping cart site and it's working great. SUPER!

  10. razn8
    Member
    Posted 4 years ago #

    Using this method, how would you open the link in a new window, such as you would with the onclick="window.open(this.href); return false;" or target="_blank" ?

  11. duncandibble
    Member
    Posted 4 years ago #

    Worked for me too; needed a link to an action on a page and worked perfectly! Thanks!

  12. Mark / t31os
    Moderator
    Posted 4 years ago #

    You could avoid the white space issue by removing the unnecessary tags..

    ?>
    <?php header('Location: http://www.mywebsite.com');

    for..

    header('Location: http://www.mywebsite.com');

    Bit silly closing PHP ?> only to then open it again straight after <?php ...

    You could also look at using the WordPress redirection function in place of the header location..

    wp_redirect('someurl', 301);

    301 is the status code to use, and of course someurl is where you'd place your URL to reirect to.. (301 is default, so not required unless you want a difference status code)

    You should also place an exit call after the redirect...

    header('Location: http://abc.de'); exit();

    or

    wp_redirect('http://abc.de'); exit();
  13. jannmirch
    Member
    Posted 4 years ago #

    It's a thing of beauty! I thought I'd be trying to figure this out for hours and I did it in a matter of minutes.

    I needed to create a child page under "newsroom" that was really a link to an existing child page of "About Us." Your simple redirect works perfectly.

    Thanks.

  14. dinman
    Member
    Posted 4 years ago #

    yay! glad i found this, as i had a request to put a "Next Blog" loop in some related blogs, using the top page nav, thusly. the template solution posted by ClaytonJames solved it handily! thank you =)

  15. dustybacon
    Member
    Posted 4 years ago #

    Very thankful for all the great solutions! Please though, a little more technical support?

    I think I might need a timed-redirect page that redirects after one or two seconds ...

    This is because I spend a lot of time promoting my site on social media (FB), I'd like a dummy re-direct page that I can attach a link of instead of my front page. If I link to my front-page it will display a blurb of the uppermost text and the images from the posts on the front-page. I want to be able to have a dummy page that redirects quickly but that has the right text and pics for such a blurb. I've coded pages with the redirects in this thread and they actually redirect within the link I'm attaching (ie in the facebook message I'm sending) thus defeating the point of the dummy re-direct page for my purposes. Hope I've been clear. Any help is appreciated :)

  16. Lectrik
    Member
    Posted 4 years ago #

    Nice! I've done this a couple of different ways such as simply using an HTML redirect but I really like this technique, particularly because it creates a template that you can package with custom themes. Thanks!

  17. sgsuneel
    Member
    Posted 4 years ago #

    Thanks a ton guys. Right on point. Helped e a lot in redirecting a page to a forum in easy steps. Took less than 3 minutes for sure.

  18. arapacana
    Member
    Posted 4 years ago #

    Awesome fix.
    Three minutes? Try ONE!

    I used this with the Constructor theme, which does not include a "Home" link in the header, which only displays pages, so I had to make a PAGE so it would show up in the header as a link... but I wanted it to go to the actual home page, not a sub page. This fix did the job perfectly.

    THANKS!!!

  19. famo
    Member
    Posted 4 years ago #

    You could also paramaterise the redirect page in a custom field. Add a new custom field called redirect_url and give it the address, then change your template to:

    <?php
    $redir_url = get_post_meta($post->ID, 'redirect_url', true);
    wp_redirect($redir_url);
    exit();
    ?>

    This way, you don't have to create a new template for each redirect you need to do.

    I've got this problem where I've put a whole stack of pages under a sub-page, but there are sites out there linking to my original page url. I don't know how to fix it apart from redirecting a whole bunch of old urls to the new page address any ideas?

    The page was at

    http://www.mywebsite.com/page/

    and now sits at

    http://www.mywebsite.com/parent-page/page/

    It wouldn't worry me if the page hierarchy was left out of the URL altogether...

    Any ideas would be greatly appreciated.

    Cheers,
    Damo

  20. Kathi Browne
    Member
    Posted 4 years ago #

    Everyone says this is so easy, and yet I'm still having trouble (embarrassed to ask, but...)

    I have a tab http://wingspouse.com/blog/my-blog that I want to redirect to http://wingspouse.com/blog so it doesn't look stupid.
    1. I created my-blog.php and put it in my theme directory with all the other phps.
    2. I edited the file to include the few lines above and saved.
    3. I added a "Page" (not a post) on my site called My-Blog and saved.

    Did I put the php file in the wrong location? Would appreciate advice.

  21. vinnikiniki
    Member
    Posted 4 years ago #

    I don't want to hi-jack the post but....
    I have a simillar problem it's probably really easy to sort...but i know zilch about PHP and i'm not sure if the rename htaccess file is necessary in my situation...

    Basically i have included wordpress in an iframe on the html page
    http://www.vinnikiniki.com/blog1.html
    I would like to make sure that whenever someone views my blog they see it within the mock windows shell.
    I am worried that if someone searches in google they will be able to see the site bear bones i.e. http://www.vinnikiniki.com/blog/index.php
    how can i work around this? Any ideas?
    Thanks!!!

  22. cdchurch
    Member
    Posted 4 years ago #

    the typical solution works (redirect.php template) EXCEPT for when you have a custom permalink structure like %postname%

    how can I fix this? what can I do?

  23. cdchurch
    Member
    Posted 4 years ago #

    nevermind. I just found http://txfx.net/wordpress-plugins/page-links-to/ which is a plugin which will do it without ANY customization. So easy. I recommend this plugin to anyone.

  24. dorf
    Member
    Posted 4 years ago #

    Thanks ClaytonJames,

    A tip of the hat to you sir.

  25. ClaytonJames
    Member
    Posted 4 years ago #

    I have since switched to using the same solution cdchurch used for this issue. I like it much, much better.

    http://wordpress.org/extend/plugins/page-links-to/

Topic Closed

This topic has been closed to new replies.

About this Topic