There are three simple steps to get what you want:
- Hook into
'template_redirect'to act before the feed is displayed. - If it is a feed send a 404 status header and
- load the 404 template.
Here is a simple plugin that does it:
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 404 Feed
* Description: Sends a 404 status code for all feeds and loads the <code>404.php</code> template.
*/
add_action( 'template_redirect', 't5_404_feed', 1 );
function t5_404_feed()
{
if ( is_feed() )
{
status_header( '404' );
locate_template( array ( '404.php', 'index.php ' ), TRUE, TRUE );
exit;
}
}
I am not so sure that 404 is the proper status code. 410 (Gone) may fit better.
Related Posts:
- How to force a 404 on WordPress
- Redirect Restricted Page to 404
- How to prevent automatic redirection of 404 errors and “incorrect” URLs?
- How do I skip wordpress’s 404 handling and redirect all 404 errors for static files to 404.html?
- How do I programmatically generate a 404?
- How do I skip wordpress’s 404 handling?
- 404 redirection and Google’s index [closed]
- Check if post is in draft or pending review?
- Why specific file directory fails to redirect but its parent folder succeeds?
- WordPress blocking/preventing viewing of .cgi file in subdirectory [closed]
- Deny access to a path (give 403 or 404 response)
- Redirect a page id url but not the page slug
- Defining a custom 404 for non-WordPress parts of site
- WordPress Auto-Redirecting on 404
- Built-In Postname Redirection vs Hard Redirects in relation to SEO and performance
- How to redirect a wrong search on my wordpress website to the error 404 page?
- WP page 404 error only on mobile
- Force 404 redirect to home?
- How can I redirect users on the new 404 page without plugin?
- How to redirect an old page url to the homepage
- Dynamic 404 page content while still keeping 404 status code?
- Redirect to home if page doesn’t exists [duplicate]
- Redirect to parent page if child does not exist
- How to redirect non existent pages/posts in wordpress using htaccess
- How to Redirect WordPress domain.com/?anyword to 404 Page?
- How do I redirect the browser to 404 page, if no posts are found in home page
- How do i make WordPress return 404 instead of redirecting on misspelled page?
- How to regenerate RSS feed URL like FeedBurner?
- How to redirect if 404 error in wordpress then redirect 404.php url
- Redirect to /404/
- Remove all feeds and return custom 404 page
- Page editing in backend redirecting to 404 page not found with url /post.php
- How do I skip wordpress’s 404 handling?
- Subpages return 404 server error
- WordPress subfolders htaccess bypassing the root htaccess RewriteRule
- Why my htacess rewrite return 404?
- How to Redirect Url to homepage?
- Stopping media file redirects
- Forcing header cache control in 404 pages
- redirect to 404 page
- Redirect certain 404 pages to parent page
- Redirect of specific words in URL ahead of website migration
- How to configure nginx to redirect requests to the uploads directory to the production server?
- Multisite 404 errors and non-www redirecting to home page
- Facebook like button that redirects?
- WordPress redirect loop on nginx + apache reverse proxy
- URL Redirect and Bulk Actions in wp_list_table
- Redirect too many times htacces switching to https
- Redirect guest if he tries to access a specific page
- htaccess 301 redirect http to https doesn’t work
- Site redirecting from http to https [closed]
- Use htaccess to redirect WordPress to static website in a subfolder
- How to redirect URL with subfolder to the same URL but without subfolder?
- Site loads very slowly (4-5 minute load time)
- If User is NOT Logged in and Page ID is not 6 – Redirect to Login
- Snippet for own (gr)avatars
- 503 Service Unavailable error was encountered
- SSL and www to non-www redirection works only on homepage – WordPress
- How to redirect if a background request is still being executed
- WordPress keeps redirecting subpages without http to https homepage after switch
- Redirect non-existent subpages to second part of url
- How to remove the [L] Flag for WordPress index .php mod_rewrite
- ReDirect subfolder link to another sub-folder and force SSL
- 404 in custom post type feed with mistake permalink
- About to migrate site to new domain
- Redirect all users to dashboard unless custom post type
- Redirecting connection from IP to localhost
- Custom JSON feed rewrite
- How to redirect 40,000 urls with the same url structure efficiently?
- Changing theme = change home page for mobile visitors?
- Redirect User on Login based on role WP 3 – Multi-Site
- Redirect old URL (with different post ID) to new URL
- Expired event redirect to parent category
- Delete Redirect Slug For Specific Post
- redirecting an entire WP site from one top level domain to another
- 404 redirect based on url
- Missing domain http://./wp-… in redirects
- All URLs Redirect to Main Page
- 301 redirects in Headway based WordPress Site
- Why I am not able to direct user to my blog section without login?
- Problem using the word “RSS” as a tag
- Import RSS as posts with redirect?
- Subdomain redirect problem
- redirect from old URL structure
- Is the default value of FORCE_SSL_ADMIN documented?
- wordpress automatic URL ‘page’ parameter rewrite
- Changing post depending upon where you’re redirected from?
- Loading /wp-content/uploads/site as /site/
- WordPress not loggin user and redirecting after custom registration
- How to manage around 90k 301 redirects after migration from old CMS
- Local domain remap with proxy : Infinite 301 redirect, bad URL typo
- Pagination redirect set in .htaccess file is not working
- Count users redirected from Facebook
- Redirecting a POST to a php script
- How to map secure.domain.com to www.domain.com or domain.com with “WordPress MU Domain Mapping” on the primary multisite domain?
- Add a simple php code snippet to redirect a single wordpress url to another
- wp_redirect() doesn’t work
- Redirect old homepage to the new one within the same site
- redirect site links form joomla to WordPress
- Why Does My Website Redirect to HTTP Before HTTPS When Accessed Without a Trailing Slash?