• Resolved bselfors

    (@bselfors)


    Hello, I need some help please.

    Related to: https://wordpress.org/support/topic/amp-redirect-issue-for-indexing-2/#post-11507333

    I updated the latest version of the plugin except for our custom template files. However, I am not sure what the best practice is when it comes to the homepage. On one hand, I want to force AMP on any mobile traffic but for our homepage, we ended up redirecting to another fallback homepage called https://flowersfaq.com/home/?amp It does not seem like good practice to 301 the homepage on mobile traffic and maybe that is why Webmaster is not indexing our site as it should…What do you think?

    
    /**
     * Redirect to URL
     */
    
    function redirectTo($url) {
        wp_redirect( $url, 301 );
        exit;
    }
     
    function curPageURL() {
     $pageURL = 'http';
     if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     $pageURL .= "://";
     if ($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
     return $pageURL;
    }
    $curl = parse_url(curPageURL());
    $ampurl = '';
    $ampurl = $curl['scheme'] ."://". $curl['host'] . $curl['path'] .'?amp' ;
    if ( !empty($curl['query']) ) {
    	$ampurl .= '&'.$curl['query'];
    }
    
    if ( empty($curl['path']) || $curl['path'] == "/" ) {
    	$ampurl = $curl['scheme'] ."://". $curl['host'] ."/home/?amp";
    }
    
    if ( is_null($_GET['amp']) && wp_is_mobile() ) {
    	redirectTo($ampurl);
    }
    

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘AMP Homepage Redirect’ is closed to new replies.