• hi – how to redirect 301 all feeds url to hom page?
    for example
    https://site.com/test/feed/
    https://site.com/test2/feed/
    https://site.com/test3/feed/
    https://site.com/Every-word/feed/
    redirect 301 to site.com
    Not just one or more url . all url have /feed redirect 301 to home page
    i test this codes and not working

    
    RewriteRule ^destinations/(.*)/feed$ /category/destination/$1/feed [L,R=301]
    
    
    RewriteRule ^feed/(.*)$ /$1 [R=301,NC,L]
    
    
    # BEGIN Feed redirect
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*/)?feed(/rss|/rss2|/atom|/rdf)?/?$ /$1 [R=301,NC,L]
    RewriteCond %{QUERY_STRING} (?|&)feed=
    RewriteRule (.*) $1/? [R=301,NC,L]
    </IfModule>
    # END Feed redirect
    
    
    /**
    * Redirect to the homepage all users trying to access feeds.
    */
    function disable_feeds() {
        wp_redirect( home_url() );
        die;
    }
    
    // Disable global RSS, RDF & Atom feeds.
    add_action( 'do_feed',      'disable_feeds', -1 );
    add_action( 'do_feed_rdf',  'disable_feeds', -1 );
    add_action( 'do_feed_rss',  'disable_feeds', -1 );
    add_action( 'do_feed_rss2', 'disable_feeds', -1 );
    add_action( 'do_feed_atom', 'disable_feeds', -1 );
    
    // Disable comment feeds.
    add_action( 'do_feed_rss2_comments', 'disable_feeds', -1 );
    add_action( 'do_feed_atom_comments', 'disable_feeds', -1 );
    
    // Prevent feed links from being inserted in the <head> of the page.
    add_action( 'feed_links_show_posts_feed',    '__return_false', -1 );
    add_action( 'feed_links_show_comments_feed', '__return_false', -1 );
    remove_action( 'wp_head', 'feed_links',       2 );
    remove_action( 'wp_head', 'feed_links_extra', 3 );
    
    
        <?php
      function cwc_disable_feed() {
        wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
    }
    add_action('do_feed', 'cwc_disable_feed', 1);
    add_action('do_feed_rdf', 'cwc_disable_feed', 1);
    add_action('do_feed_rss', 'cwc_disable_feed', 1);
    add_action('do_feed_rss2', 'cwc_disable_feed', 1);
    add_action('do_feed_atom', 'cwc_disable_feed', 1);
        ?>
    

    i clear cache and test again but not working this codes
    please help me to redirect /feed Without plugin

Viewing 1 replies (of 1 total)
  • Why in the world do you want to do that? You’re taking a feature away from your more adept users… probably thinking that will build readership.

    The right way is to set feeds to excerpts instead of full posts. Those people who appreciate feeds will follow the read more link back to your site to read the full article if you wrote or provided something interesting.

    Anyway, here’s a tool to build redirects that work via htaccess without the extraneous code.

    https://www.rapidtables.com/web/tools/redirect-generator.html

    That tool can also assist you with PHP if you prefer.

Viewing 1 replies (of 1 total)
  • The topic ‘how to redirect feed?’ is closed to new replies.