WordPress.org

Forums

block search engine from certain page using php script (3 posts)

  1. Bhiroe
    Member
    Posted 3 years ago #

    I want to create a page that can not be visited by search engine bots, but I just want to use php script to block it, is there anything that can help me ...........

  2. Jam Viet
    Member
    Posted 3 years ago #

    using this code in the loop like:
    if (is_page()) {
    $something = $_SERVER['HTTP_USER_AGENT'];
    if(preg_match('/google/i', $something)) {
    wp_redirect(home_url('/'));
    }

    }

  3. Bhiroe
    Member
    Posted 3 years ago #

    thank's mcjambi
    but I don't know how to apply on my 404 page, this is my 404 page:

    <div class="hentry post 404">
    	<h1><?php _e('Not Found', 'default'); ?></h1>
    	<div class="entry">
    		<p><?php _e('Apologies, but we were unable to find what you were looking for. Perhaps  searching will help.', 'default'); ?></p>
    
    		<?php get_search_form(); ?>
    
    		<p>&raquo; <a href="<?php bloginfo('url'); ?>"><?php _e('Or go to the homepage', 'default'); ?></a></p>
    	</div>
    </div>

Topic Closed

This topic has been closed to new replies.

About this Topic