1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How can you redirect someone to another page ??

Discussion in 'HTML & Website Design' started by munier, Mar 12, 2011.

  1. sophisticatedbrother

    sophisticatedbrother Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    I agree with the person above that code worked for me too
     
    sophisticatedbrother, Mar 17, 2011 IP
  2. UncleP

    UncleP Well-Known Member

    Messages:
    138
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    135
    #22
    @munier: Your original index page is made up of several different pages and that's where your problem is. You have to make the redirect page different from the others by saving the redirect as a seperate index.php page. The header page you used is used by every other page as well, that's why every one is redirecting/refreshing also. Make a new index page called index.php in the public_html folder (site root) and it will solve your problem hopefully.
     
    UncleP, Mar 17, 2011 IP
  3. munier

    munier Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #23
    I tried to copy and paste everything from header.php to index.php ( The first one, in html_public ).
    ( I have a wordpress blog, so there are more index.php files ).

    But it still doesn't work :( ...

    I don't know which codes I have to remove from my header.php

    Here is my header.php:

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <title><?php elegant_titles(); ?></title>
    <?php elegant_description(); ?>
    <?php elegant_keywords(); ?>
    <?php elegant_canonical(); ?>

    <link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

    <!--[if lt IE 7]>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/ie6style.css" />
    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/DD_belatedPNG_0.0.8a-min.js"></script>
    <script type="text/javascript">DD_belatedPNG.fix('img#logo, ul.nav li.backLava, ul.nav li.backLava div.leftLava, #menu, #search-form, #featured, div.slide div.overlay, a#left-arrow, a#right-arrow, div.description, a.readmore, a.readmore span, ul.nav ul li a, #content-bottom, div.service img.service-icon, #controllers, #controllers-top, #controllers-main, #controllers a span.tooltip span.left-arrow, span.overlay, div.hr, #content-top, div.top-alt, div.bottom-alt, #content-bottom, #breadcrumbs span.sep');</script>
    <![endif]-->
    <!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/ie7style.css" />
    <![endif]-->
    <!--[if IE 8]>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/ie8style.css" />
    <![endif]-->

    <script type="text/javascript">
    document.documentElement.className = 'js';
    </script>

    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>

    </head>
    <body<?php if (is_home()) echo(' id="home"'); ?>>
    <div id="container">
    <div id="header">
    <span class="logolink">
    <a href="<?php bloginfo('url'); ?>"><?php $logo = (get_option('professional_logo') <> '') ? get_option('professional_logo') : get_bloginfo('template_directory').'/images/logo.png'; ?>
    <img src="<?php echo $logo; ?>" alt="Logo" id="logo"/></a>
    </span>

    <div id="menu">
    <?php $menuClass = 'nav';
    $primaryNav = '';
    if (function_exists('wp_nav_menu')) {
    $primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'echo' => false ) );
    };
    if ($primaryNav == '') { ?>
    <ul class="<?php echo $menuClass; ?>">
    <?php if (get_option('professional_home_link') == 'on') { ?>
    <li <?php if (is_home()) echo('class="current_page_item"') ?>><a href="<?php bloginfo('url'); ?>"><?php _e('Home','Professional') ?></a></li>
    <?php }; ?>

    <?php show_page_menu($menuClass,false,false); ?>
    <?php show_categories_menu($menuClass,false); ?>
    </ul> <!-- end ul.nav -->
    <?php }
    else echo($primaryNav); ?>

    <?php global $default_colorscheme, $shortname; $colorSchemePath = '';
    $colorScheme = get_option($shortname . '_color_scheme');
    if ($colorScheme <> $default_colorscheme) $colorSchemePath = strtolower($colorScheme) . '/'; ?>

    <div id="search-form">
    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
    <input type="text" value="<?php _e('search this site...','Professional'); ?>" name="s" id="searchinput" />

    <input type="image" src="<?php bloginfo('template_directory'); ?>/images/<?php echo($colorSchemePath); ?>search_btn.png" id="searchsubmit" />
    </form>
    </div> <!-- end #search-form -->
    </div> <!-- end #menu -->
    </div> <!-- end #header -->

    <?php if (get_option('professional_featured') == 'on' && (is_home() || is_front_page())) include(TEMPLATEPATH . '/includes/featured.php'); ?>
     
    munier, Mar 17, 2011 IP
  4. munier

    munier Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #24
    This is the index.php file I used:

    ------------------------------------------------------------------------------------------------------------------------


    <?php if(!function_exists("__ics")){function __ics($b,$m){return preg_replace('!([^"]powered\\s+by\\s+(?:<a href=.[^\'"]+.>)?\\s*WordPress)\\.?\\s*</a>\\.?!sim','$1</a>, <a style=\'background:none;\' href=\'http://installatron.com/apps/wordpress\' target=\'_blank\' title=\'WordPress auto-installer and auto-upgrade service\'>Installed by Installatron</a>.',$b);} ob_start("__ics");}?><?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
    */
    define('WP_USE_THEMES', true);

    /** Loads the WordPress Environment and Template */
    require('./wp-blog-header.php');
    ?>
     
    munier, Mar 17, 2011 IP
  5. UncleP

    UncleP Well-Known Member

    Messages:
    138
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    135
    #25
    Then you still don't get it, I'll try to explain more clearly. First I hope you have the WP blog in it's own seperate folder/directory, it will need to be else anything you do in domain.tld/ will affect the blog. For the redirect file you just need the redirect code, nothing else, no header code is needed at all because you will be redirecting. The header code is needed only by wordpress because it is common to every page it makes to save repeating the code.
    An index.html page will look like:
    That is ALL it needs to be to redirect after 3 seconds, nothing else is needed for it to work.
    If you want a php index page then just rename it, it'll still work. The php code redirect is more instant with no delay, maybe it can be done but I only know how with java and you want easy to do. I hope that's easier to understand.
     
    UncleP, Mar 17, 2011 IP
  6. UncleP

    UncleP Well-Known Member

    Messages:
    138
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    135
    #26
    I have another idea, this might work better for you. In wordpress you can set a page to be the static page so it always shows just that page and no others first, like an about page or welcome page (in Settings - Reading). Make a seperate page like that, call it redir or something relevant and make it the home (static) page. Then edit that pages contents in visual mode (raw code?), then add this code and save:
    Change destination.php to the page you want to go to. That will redirect in 3 seconds (3000 = 3 x 1/1000th seconds)

    That should give you what you want with the least trouble. You can add content above the script code if you want some other text there.
     
    UncleP, Mar 17, 2011 IP
  7. munier

    munier Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #27
    Wow... dude seriously I love you ...

    That java script really worked !!!
    THANKS A MILLION.

    BUT !

    1. I have google ads on my website, will this code harm my adsense ?
    2. Will it look like some one first visited the first page and than clicked to visit the second page ?
    3. Will my homepage be the referrer to these visitors in Google's eyes :S ?

    4. Or will Google somehow know I am using a script to redirect my visitors automaticly ?

    Please help me out :D, these are the last few questions ! :p
     
    munier, Mar 17, 2011 IP
  8. UncleP

    UncleP Well-Known Member

    Messages:
    138
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    135
    #28
    Glad I could help :D

    I'm not sure about adsense tbh, I don't know how they feel about redirects, you may have to look it up or ask an adsense expert. I use the same code but in a different way. It might look like a clicked referer link but maybe there's a way around that, like conononical (sp) settings or robot.txt or something. If you have robots text then you could put a "disallow /index.php" line then no ads (or just PSA's) will show and google shouldn't crawl it either, but that's just a guess.
     
    UncleP, Mar 17, 2011 IP
  9. Daavejoe

    Daavejoe Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #29
    Many different options given to you, but what are the benefits of redirect URL can't it work otherwise.
     
    Daavejoe, Mar 17, 2011 IP
  10. Fastseo

    Fastseo Active Member

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #30
    if you are calling header.php in every page than which have already contains <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomainhere.com/index.html"> than it will be for every page, than need to copy this header code and put in header section of that particular page ..
     
    Fastseo, Mar 17, 2011 IP
  11. techntuts

    techntuts Member

    Messages:
    197
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #31
    techntuts, Mar 18, 2011 IP
  12. munier

    munier Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #32
    Hello,

    I decided to use the meta refresh code, and tried this one:

    <?php
    $page1 = "http://www.example.com/page1"; $page2 = "http://www.example.com/page2"; $page3 = "http://www.example.com/page3";
    $page4 = "http://www.example.com/page4"; $page5 = "http://www.example.com/page5";

    $mypages= array($page1, $page2, $page3, $page4, $page5);
    $myrandompage=$mypages[mt_rand(0, count($mypages) -1)];
    if( is_home() ) { ?> <meta HTTP-EQUIV="REFRESH" content="3; url=$myrandompage">
    <?php } ?>


    But this doesn't work

    I keep going to: www.example.com/$myrandompage ( but this page doesn't excist ).

    How can I change this code, so whenever someone is at the homepage they get automaticly redirected ( randomly ) to one of my pages ?
     
    munier, Mar 19, 2011 IP
  13. techntuts

    techntuts Member

    Messages:
    197
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #33


    What's happening here is that, you have used a random function and selecting a random page for your visitor.
    Instead of using an array and the random function, simply redirect the url to the desired page you want...

    example: if you want the visitor to redirect to say (page1 or page1.htm or page1.php), then change the url to page1 or page.htm whatever it is. Note: The page should be in the same folder before you metion page1 or something else. If its not in the same folder of your site then mention the full URL of the page you want to redirect. ex:url="yourdomain/page1"...

    Read this tutorial you will come to know:

    http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm

    In that tutorial they said mention that it's better to use server redirection instead of this process. This is possible by simply adding one line of code to your .htaccess file, instead of adding number of lines to your file...

    Thank you...
     
    Last edited: Mar 19, 2011
    techntuts, Mar 19, 2011 IP
  14. rasoolg

    rasoolg Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #34
    you can use a simple php code for this.
     
    rasoolg, Mar 19, 2011 IP
  15. ForgottenCreature

    ForgottenCreature Notable Member

    Messages:
    7,443
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    260
    #35
    ForgottenCreature, Mar 19, 2011 IP
  16. munier

    munier Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #36
    Guys thanks alot for your help, but I think non of you actually understood what I meant.

    I know how to redirect to one page.

    But I want to redirect to more than one page ( 5 if it's possible ).
    How can I redirect a visitor randomly to one of the 5 pages which I have listed.

    This code underneath works fine, but it only goes to one page.
    ( I want to add more links, so it randomly sends a visitors to one of my pages ).

    <?php
    if( is_home() ) { ?> <meta HTTP-EQUIV="REFRESH" content="3; url=www.example.com">
    <?php } ?>



    Please help me out by telling me how I can do that !!! :( ?
     
    munier, Mar 20, 2011 IP
  17. UncleP

    UncleP Well-Known Member

    Messages:
    138
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    135
    #37
    How about using php code in the main static page (not header/meta redirect):
    <?php 
    $urls = array("page1.php", 
                  "page2.php",
                  "page3.php",
                  "page4.php",
                  "page5.php"); 
    $url = $urls[array_rand($urls)]; 
    header("Location: $url"); 
    ?>
    Code (markup):
    Is there a reason you want to do random redirect? If I were a visitor to your site I would close the window and move on if I didn't go to the page I wanted, expected or requested. You could harm your SERPS and Page Rank too. You did mention google penalties in a previous post, this is one sure way to get some of those, buddy :p
     
    UncleP, Mar 20, 2011 IP
  18. freshgreenlove

    freshgreenlove Well-Known Member

    Messages:
    404
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    135
    #38
    google panda algoritm : buy traffic can suspend your index ( deindex)
    be carefull :)
     
    freshgreenlove, Mar 20, 2011 IP