View Single Post
Old 03-28-2017, 05:35 AM  
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,391
The easiest way to do it is: put this code into header.php of your WP theme:

Code:
if (!is_user_logged_in() && is_singular('post')) {
    if (wp_redirect('http://www.gfy.com/')) {
        exit;
    }
}
The code must be placed right after the first "<?php" line in header.php (before "<!DOCTYPE html>" or any other HTML code). Just make sure to replace 'http://www.gfy.com/' with URL of your login/registration page.

There is one problem, however. The search engines will not be able to see the full articles too. Course it's not a problem to make an additional check to find out if it's an SE bot or a human, to perform redirect for human surfers only, but I guess that search engines will consider it as cloaking which is a black SEO method...

So alternatively you can use this code:

Code:
if (!is_user_logged_in() && strpos(wp_remote_request(), '#more') !== false) {
    if (wp_redirect('http://www.gfy.com/')) {
        exit;
    }
}
It won't block search engines from crawling your full-text pages, but it won't block your surfers from visiting them too, if the post URL is opened in the browser directly. The redirect trick will work only in case if a surfer has clicked "read more".
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote