Results 1 to 10 of 10
  1. #1
    Frank Benjamin is offline Private Member
    Join Date
    April 2008
    Posts
    378
    Thanks
    9
    Thanked 46 Times in 35 Posts

    Default Trying to Forward but 301 Redirect Wont Work

    I am working on a buddy's site right now (powered by WP) and I am trying to forward a templated page made from a php script to a custom page so I can optimize the title, url and description.

    The code makes a bio page for handicappers and is run by a script from sportscapping.com. An example of a page created from this script is mydomain.com/sportscapping.php?capper/capper/355/Tony%20Karpinski/AF236_366.

    I have created the page mydomain.com/tony-karpinski-sports-picks/.

    I would like to forward the big ugly .php page to this nice and clean page.

    However, 301 Redirect via the htaccess page doesn't work. I have also tried a redirect plugin (Pretty Links) which is actually for cloaking affiliate links. But I thought I would try it anyway and it doesn't work either.

    Any suggestions for a solution to my issue here?

    Thanks in advance!

  2. #2
    GaryTheScubaGuy's Avatar
    GaryTheScubaGuy is offline In Memorium, 1966-2018
    Join Date
    December 2008
    Location
    Malta
    Posts
    745
    Blog Entries
    22
    Thanks
    223
    Thanked 430 Times in 205 Posts

    Default

    Have you tried Yoast's SEO plugin? SEO Ultimate? Turn off all of your plugins and try each. Without the handling source code its difficult to identify the issue.
    GaryTheScubaGuy

  3. #3
    Frank Benjamin is offline Private Member
    Join Date
    April 2008
    Posts
    378
    Thanks
    9
    Thanked 46 Times in 35 Posts

    Default

    the site does have Yoast's SEO and I tried manually adding the 301 Redirect to the .htaccess file as well as through Yoast's plugin.

    I was thinking it had something to do with the script and not a plugin. I don't have problems with any other redirect. I tested other 301 Redirects via the .htaccess file and they work perfectly fine.

    Here is the source code. The original site simple had a header, sidebars and footer wrapped around this code and it produced a plethora of pages including bio pages, premium and free picks for each sports, etc. I am far from a programmer. The little I know, I taught myself messing around with WP themes and plugins. I know only enough to make me dangerous.

    Let me know if there are any other suggestions.

    <?php

    ################################################## #####
    # SETTINGS - you can modify these setting to your needs

    $mode = 'standard'; # please select mode: standard, fopen, curl, iframe
    $frame_height = 1400; # applied to iframe type only

    ################################################## #####
    # SPORTSCAPPING content STARTS here
    # Do not modify unless you 100% about what you're doing

    $sportscapping_site_path = 'http://www.sportscapping.com';
    $your_partner_code = 'XXXX_XXX';

    $params_string = getenv('QUERY_STRING');
    $params_array = explode('/', $params_string);

    if (is_array($params_array))
    foreach ($params_array as $one_param) {
    unset($temp_params_array);
    $temp_params_array = explode(',', $one_param);
    $named_param[$temp_params_array[0]] = $temp_params_array[1];
    }

    if (!$params_array[0]) $params_array[0] = 'premium_picks';

    if ($params_array[0] == 'schedule') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/schedule/' . $named_param['league_id'] . '/' . $named_param['event_date'] . '/' . $named_param['game_id'] . '/' . $named_param['picks_type'];
    if ($params_array[0] == 'premium_picks') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/premium_picks/menu/' . $named_param['leg'] . '/' . $params_array[1];
    if ($params_array[0] == 'free_picks')
    {
    $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/free_picks';
    $url .= ($params_array[2])? '/'.$params_array[2]:'';
    }
    if ($params_array[0] == 'leaderboard') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/leaderboard/menu/10/' . $named_param['leg'];
    if ($params_array[0] == 'capper') $url = $sportscapping_site_path . '/new/export/?' . $params_array[4] . '/export/capper/' . $params_array[2] . '/overall';
    if ($params_array[0] == 'top_trends') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/top_trends/menu/' . $named_param['leg'] . '/10';
    if ($params_array[0] == 'top_cappers') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/top_cappers/full/menu/' . $named_param['leg'];

    if ( $mode == 'standard' ) echo file_get_contents( $url );
    if ( $mode == 'fopen' ) echo get_file( $url );
    if ( $mode == 'curl' ) echo get_file_curl( $url );

    if ( $mode == 'iframe' )
    {
    if ($params_array[0] == 'premium_picks') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/premium_picks/menu/' . $named_param['leg'] . '/' . $params_array[1];
    if ($params_array[0] == 'free_picks') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/free_picks';
    if ($params_array[0] == 'leaderboard') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/leaderboard/menu/10/' . $named_param['leg'];
    if ($params_array[0] == 'capper') $url = $sportscapping_site_path . '/new/export/?' . $params_array[4] . '/export/capper/' . $params_array[2] . '/overall';
    if ($params_array[0] == 'top_trends') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/top_trends/menu/' . $named_param['leg'] . '/10';
    if ($params_array[0] == 'top_cappers') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/top_cappers/full/menu/' . $named_param['leg'];

    echo
    '<script language="javascript" type="text/javascript">

    function iFrameHeight() {
    var h = 0;
    if ( !document.all ) {
    h = document.getElementById(\'blockrandom\').contentDo cument.height;
    document.getElementById(\'blockrandom\').style.hei ght = h + 60 + \'px\';
    } else if( document.all ) {
    h = document.frames(\'blockrandom\').document.body.scr ollHeight;
    document.all.blockrandom.style.height = h + 20 + \'px\';
    }
    }
    </script>

    <iframe onload="iFrameHeight()" id="blockrandom" name="iframe" src="' . $url . '" width="100%" height="' . $frame_height . '" scrolling="auto" align="top" frameborder="0"
    class="wrapper">This option will not work correctly. Unfortunately, your browser does not support Inline Frames</iframe>';
    }

    function get_file_curl($url)
    {
    $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)';

    # start CURL
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url); // base page
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); // user agent
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return result to variable
    # get actual result to variable
    $content = curl_exec ($ch);
    # close CURL
    curl_close ($ch);

    return $content;
    }

    function get_file($url)
    {
    $data = fopen($url,"rb");
    $content = '';
    if ($data)
    {
    while (!feof($data))
    {
    $content .= @fread($data, 100000);
    }
    @fclose($data);
    }
    return($content);
    }

    # SPORTSCAPPING content ENDS here
    ##################################################

    ?>

  4. #4
    universal4's Avatar
    universal4 is online now Forum Administrator
    Join Date
    July 2003
    Location
    Courage is being scared to death...and saddling up anyway. John Wayne
    Posts
    31,976
    Thanks
    3,685
    Thanked 8,694 Times in 5,545 Posts

    Default

    My first guess is the issue with the redirect my be the %20 in the url.

    I do not know for sure, but maybe the htaccess doesn't handle the space well.

    I would try a 301 stopping at Tony and if that works, see if you can modify the code to NOT drop a space (%20) in the url.

    Rick
    Universal4

  5. #5
    Frank Benjamin is offline Private Member
    Join Date
    April 2008
    Posts
    378
    Thanks
    9
    Thanked 46 Times in 35 Posts

    Default

    I don't know where that comes from. It is the php code and I am far from a programmer. I might just have to leave it the way it is.

    I'll have to check with the site that makes the script.

  6. #6
    universal4's Avatar
    universal4 is online now Forum Administrator
    Join Date
    July 2003
    Location
    Courage is being scared to death...and saddling up anyway. John Wayne
    Posts
    31,976
    Thanks
    3,685
    Thanked 8,694 Times in 5,545 Posts

    Default

    If it ends up being the space, remove the space from the username where the page is created.

    I am not sure if that is the issue, but if the page rewrites when you stop before the %20 then that is a likely suspect.

    Rick
    Universal4

  7. #7
    Frank Benjamin is offline Private Member
    Join Date
    April 2008
    Posts
    378
    Thanks
    9
    Thanked 46 Times in 35 Posts

    Default

    The script creates the page automatically. There is no such page actually in wordpress. The only page on the server is the sportscapping.php file that contains the script.

    If I manually remove the %20 from the link, it works fine. The problem is that throughout the site where any script has a link to the biopages, the space is automatically placed. I can't do anything about it - or at least don't know how to.

    However, I tried doing a 301 without the space and it still didn't work. I am thinking it has something more to do with the script. Maybe it calls from a database on the affiliate programs servers or something. It might be something I just can't work around unfortunately.

    That being said, I could manually create each page and place another php script that will produce the same content, but the links will all point to the ugly script produced links. Since sportscapping.php is already blocked in the robots file, and all the links that the script produces are nofollow, this might be my best best for on-site SEO. Theoretically, if the nofollows and robot.txt file do their jobs correctly, Google won't see the duplicate pages and the manually created pages will be indexed by Google and other search engines. Also, since the bio pages that I make look just like the ones from the script (it is wrapped in the wordpress template) people would be non the wiser as they surf between the two types depending on the links they use. - Does that make sense?
    Last edited by Frank Benjamin; 11 December 2013 at 4:59 pm.

  8. #8
    Frank Benjamin is offline Private Member
    Join Date
    April 2008
    Posts
    378
    Thanks
    9
    Thanked 46 Times in 35 Posts

    Default

    Got a little help from another webmaster site. The solution was a Rewrite Condition.

    RewriteCond %{QUERY_STRING} ^capper\/capper\/355\/Tony20%Karpinski\/AF236_366$
    RewriteRule (.*) http://mydomain.com/tony-karpinski-sports-picks/? [R=301,L]

  9. #9
    clarar's Avatar
    clarar is offline Restricted Account
    Join Date
    October 2011
    Posts
    306
    Thanks
    55
    Thanked 133 Times in 89 Posts

    Default

    What I saw on internet is that you need to reorganize the redirection lines in the .htaccess file moving them before the # Wordpress line.

    That solves the issue

  10. #10
    Frank Benjamin is offline Private Member
    Join Date
    April 2008
    Posts
    378
    Thanks
    9
    Thanked 46 Times in 35 Posts

    Default

    Quote Originally Posted by clarar View Post
    What I saw on internet is that you need to reorganize the redirection lines in the .htaccess file moving them before the # Wordpress line.

    That solves the issue
    Thanks for the reply, but you are a little late and also if you followed along you the 301 redirection isn't working....and I am fully aware that they need to be above the Wordpress code.

    I posted the solution above.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •