Well those are two different things:
-
A redirect means they are not accessible any more at all.
-
noindex just means that search engines ignore it while it is still accessible if you access the URL.
So I’d recommend option 1.
This is a simple way of doing this that you can improve an. (E.g. this expects to have a static front page set and doesn’t handle any other situation)
function wpse_211889_template_redirect()
{
if ( ! is_page() ){
return;
}
$frontpage_ID = get_option('page_on_front');
global $post;
if( $post->post_parent && $frontpage_ID === $post->post_parent )
{
wp_redirect( home_url() );
exit();
}
}
add_action( 'template_redirect', 'wpse_211889_template_redirect' );
Related Posts:
- How To Fix 404 errors caused by Google Indexing WordPress In Subdirectory
- PHP header(Location: …): Force URL change in address bar
- php refresh current page?
- Host the wp-admin on another domain?
- WordPress localhost site redirect to live site
- WordPress Redirect All HTTP requests to HTTPS via .htaccess
- wp_redirect() function is not working
- My wordpress multisite homepage redirects to signup page
- Prevent access to single post types
- WordPress install enters an infinite loop
- WordPress HTTPS redirect loop
- 301 redirect not working through .htaccess
- handling login/logout redirects
- Why does WordPress automatically redirect URLs with the parameter “name=” to a different 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
- Check if post is in draft or pending review?
- How to hide that a certain non-WordPress directory exists on the server?
- Redirect “any page/page/number/” to “any page”
- Redirect deleted posts to category archive
- WordPress multisite htaccess redirection to new domain
- Can WordPress pass through a call to an external API and return the result directly to the client?
- Redirecting old post url to 404 in wordpress using htaccess
- How to redirect subcategories to a page?
- Migrating from http to https
- How to redirect to home page after registration?
- CNAME vs A Record for WWW – with 301 Redirects
- Any action in wordpress redirects me to home page
- Stuck In a Redirect Loop
- Redirect to Current Page after Login
- Login redirect problem
- Adding rewrite rule dynamically for search results redirecting to 404 URL
- how to setup .htaccess: redirect/ /%postname% to /%category%/%postname%
- Redirect some of the languages on a multi-language site
- How to redirect to specific url if contains specific text in url?
- Redirecting old permalink structure to new in htaccess
- WordPress redirect, output headers already sent
- Why is there a status message “302 Found” on top of the site?
- !is_admin() condition turns true in admin pages
- How to forward all requests starting with a specific folder name to the same folder
- WordPress index.php seems to perform unwanted redirect 301
- Issue redirecting ‘blog’ to ‘news’ in WordPress using .htaccess
- Use two different index pages
- How to redirect from one WP site to another
- Redirect /home to home.php
- WordPress localhost site always redirect to live site [closed]
- Redirect wordpress website’s subpage to root [closed]
- Redirect old query string URLs to new add_rewrite_rule URL
- WordPress Permalink Problem 404
- How can I set up a splash page that is redirected to only one time for the visitor? [closed]
- Temporary Infinite Redirect Loop
- Interested in redirection techniques for one-page themes
- Select post from dropdown and add query args not working
- Trying to map a PURL like url to a page
- A question about .htaccess
- Add new post redirection [closed]
- Blog keeps redirecting to the contact page
- Can’t login to WordPress admin panel after changing domain to use WordPress pages as a fallback from React
- WordPress Pagination – 301 Redirect Issue
- Why do my new WordPress pages redirect to home / staging site?
- WordPress multi domain: page redirect to main domain whenever WordPress do the URL guessing issue
- Puzzled at HTTP/2 301 response header
- date based redirect in wordpress
- Applying ‘middleware’ to a url before redirecting? Does WP have built in mechanism for this?
- How to regenerate RSS feed URL like FeedBurner?
- How to avoid redirect 302 in wordpress to the author pages?
- ErrorDocument 410 gives me back a 302 header
- ERR_TOO_MANY_REDIRECTS when switching from good database to old database
- Redirect to /404/
- WordPress Staging site is redirecting to live and lost the child theme
- Mailjet Email Subscription + Redirect w/ Custom Template Fails
- domain redirects to subdomain
- htaccess Redirect 301 doesn’t work. How to debug?
- Having a different landing page for returning users
- How to create multiple Rewrite-Rule for various site in single htaccess?
- Redirect after plugin activation
- Redirect affecting development folder
- change home_url and site_url but don’t redirect to home_url and site_url on load
- How do I skip wordpress’s 404 handling?
- All devices on my network redirect me to an old domain
- how to write 301 redirect code for woocommerce product
- My WordPress site redirects to port 8082
- wp-login.php redirect problem
- How to redirect 404s that generated for css&JS files?
- International characters in slugs to redirect to
- How to Block WordPress from subdomain?
- login page not working [closed]
- Debugging a redirect loop affecting only certain pages
- WordPress redirect to splash page once a day for the first week
- after logout, get_current_user_id still holds value
- noheader on the user/frontend side
- WordPress redirect from one directory to another but exclude wp-admin and wp-login.php
- How can I redirect foreigners by IP to other URL in WordPress?
- How to change Ugly link?
- WordPress site redirecting to developers URL
- How to use the HTTP API (wp_remote_get) instead of cURL?
- How to redirect users without permission to view content to a custom page?
- redirect the root of a domain, while leaving the www version unredirected