AdSense on Protected Pages

Discussion in 'Setting-up protection' started by erikcw, Dec 30, 2004.

  1. erikcw

    erikcw New Member

    Joined:
    Nov 15, 2004
    Messages:
    54
    Hi All,

    I am using new_rewrite to protect my content. I would like to ad Google AdSense onto protected pages, but can't figure out how to get it to work. For the AdSense ads to work, the google adsense web spider needs to be able to access the protected pages.

    How can I set this thing up to allow the google mediabot to access my pages?

    Thanks!
    Erik
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Erik,
    please ask Google support if there is a way to detemine if it is Google mediabot accesing your pages.
  3. erikcw

    erikcw New Member

    Joined:
    Nov 15, 2004
    Messages:
    54
    I've emailed google - if it helps, I have noticed in my server logs that the user agent is called "google mediabot". Can some workaround be written for .htaccess that lets mediabot through without authentication?
  4. erikcw

    erikcw New Member

    Joined:
    Nov 15, 2004
    Messages:
    54
    Here is what I heard back from google:

    Hello Erik,


    Thank you for your email. If you would like to display Google ads on pages
    behind a login, you will need information about our crawlers.


    The user-agent 'Mediapartners-Google/2.1' is used by our crawlers when
    indexing content for Google AdSense. Requests from our content crawlers
    can come from any of the IP addresses in the following range: 66.249.64.1
    - 66.249.79.254 .


    By allowing our crawlers to gain access to your pages behind the login,
    you will be able to display relevant ads targeted towards your content.


    Please feel free to reply to this email if you have additional technical
    questions or concerns. For general program or account questions, please
    email adsense-support@google.com.


    Sincerely,


    Mike
    The Google AdSense Team
  5. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Mike,
    edit file amember/plugins/protect/php_include/check.inc.php
    find lines:
    PHP:
    /* //allow access for google-bot
    if (preg_match('/^googlebot/i', $_SERVER['HTTP_USER_AGENT']))
        return;
    */
    add after that:
    PHP:
    if (preg_match('/^Mediapartners-Google/i'$_SERVER['HTTP_USER_AGENT']))
        return;
    This hack will work if you are using php_include or mod_rewrite+php_include protection. If you are using another protection method, let me know which.
  6. erikcw

    erikcw New Member

    Joined:
    Nov 15, 2004
    Messages:
    54
    Thanks for the reply Alex! I am acctually using the new_rewrite plugin - can you post a hack for that?

    Thanks!

    Erik
  7. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Then hack is little more complicated.
    Please edit .htaccess file in your protected folder (do it via webhosting control panel -> file manager, it is usually not available via ftp).

    After line
    Code:
    RewriteEngine On
    add lines:
    Code:
    #allow access for Google MediaBot
    RewriteCond %{http_user_agent} ^Mediapartners-Google
    RewriteRule ^(.*)$ - [L]
    
  8. sdstren

    sdstren New Member

    Joined:
    Nov 30, 2007
    Messages:
    14
    I found this old thread today while trying to figure out how to implement AdSense on my site. I can't figure out how to get the .htaccess file edited. I downloaded it from the server to my machine and made the above mentioned edits, but the file permissions on the .htaccess file on the server will not let me overwrite it. I cant see the file in my server control panel to change the permissions, I can only access it by specifying the file name in the 'file to edit' field. But, then when I go to save it, it won't let me. It says permission denied. Does anyone know of a way to change the permissions on the .htaccess file from within amember, and if so, what should the be? 600 would be my guess. Please help!

    Sandi
  9. calisolllc

    calisolllc Member

    Joined:
    Feb 19, 2007
    Messages:
    194
    Most filemanager systems don't show hidden files (i,e they begin with a ".") there is normally a switch in your filemanager programs that either say "view hidden files" or allow you to put "-al" in the switch field.
    set the permissions to allow editing. edit the file and reset permissions back to their original (DON'T FORGET to do this)
    IF this explanation doesn't make sense to you then best you have someone do it for you.
  10. sdstren

    sdstren New Member

    Joined:
    Nov 30, 2007
    Messages:
    14
    I understand exactly what you are saying. My FTP program (ipswitch) has no provision for viewing hidden files. Can you tell me what the permissions/ownership is supposed to be for the .htaccess file? You would think that the amember program would cause it to make me the owner with write permissions, but it wont let me modify the file. I can download it, open it for viewing in my control panel, but if I try to save a new copy I get permission denied. Is this a bug? Why don't I own the file with write permissions???

    Please help.

    Sandi
  11. earthchanges

    earthchanges New Member

    Joined:
    Aug 22, 2006
    Messages:
    23
    Is this how the code in the above thread is entered at the start of the file:

    <?php

    /* //allow access for google-bot
    if (preg_match('/^googlebot/i', $_SERVER['HTTP_USER_AGENT']))
    return;
    if (preg_match('/^Mediapartners-Google/i', $_SERVER['HTTP_USER_AGENT']))
    return;
    */

    If this is wrong, please show me how to do it correctly.
  12. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Yes seems to be correct.
  13. mikica123

    mikica123 New Member

    Joined:
    Apr 16, 2010
    Messages:
    14
    Hello,
    I am web coding newbee but, I have set my adsense account to display ads on protected pages by amember with post method; new rewirite simply by adsense account settings, only thing you need to do is ; Adsense acc->settings->check authentic locations-> (here you need to verify your protected page with webmaster tools sitemap + head or file verifyer.
    you have 3 options:
    get
    post
    .htaccess
    ...for new rewrite you select post with paramethers: amember_login & amember_pass
    and with amember script give Google his username and pass, and enter that info into above atributes, simple as that :)

    I had problems with submiting sitemap with webmastertools but have temporarly deleted .htacess file (backup it frist) then made sitemap submit, and uploaded .htacess file back.
    Then had no problem with linkinkg adsnese auth. link with amember protected pages.

Share This Page