Support » Plugin: AMP » Disabled AMP but Redirection Issue

  • Resolved kumarpalshah19

    (@kumarpalshah19)


    Hi,

    I wanted to remove AMP pages from my blog and that’s why I disabled AMP plugin. After disabling it, I added below code to .htaccess file.

    # Redirect AMP to non-AMP
    RewriteEngine On
    RewriteCond %{REQUEST_URI} (.+)/amp(.*)$
    RewriteRule ^ %1/ [R=301,L]

    After adding the code above, on opening AMP URL it shows the main page (non-AMP).

    Now, the issue is –
    When I open main page it opens the main page and when I open AMP page (?amp at the end) it opens the main page but URL remains with ‘?amp’. Below are the examples for better understanding.
    Main Page: https://www.insidetechno.com/youtube-channels-users-for-best-pubg-videos/
    AMP Page: https://www.insidetechno.com/youtube-channels-users-for-best-pubg-videos/?amp

    You can see that in both cases it opens main page.

    So is this redirection correct? It can cause copy content issue?

    OR “?amp” URLs should automatically redirect to main URL only? If yes, how can I do that?

    I’m confused about this redirection. Please help.

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

Viewing 1 replies (of 1 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Hi. There isn’t any real problem for users who access a URL like:

    https://www.insidetechno.com/youtube-channels-users-for-best-pubg-videos/?amp

    This URL has the canonical link as:

    <link rel="canonical" href="https://www.insidetechno.com/youtube-channels-users-for-best-pubg-videos/" />

    So search engines will thus ignore ?amp. And mobile users who share the page with someone else will have ?amp automatically removed (at least in Chrome).

    If you really don’t want the query param sticking around, then you can do something like this in a plugin:

    add_action( 'template_redirect', function() {
        if ( isset( $_GET['amp'] ) ) {
            wp_safe_redirect( remove_query_arg( 'amp' ), 301 );
            exit;
        }
    } );
    • This reply was modified 2 years, 3 months ago by Weston Ruter.
Viewing 1 replies (of 1 total)
  • The topic ‘Disabled AMP but Redirection Issue’ is closed to new replies.