Block indexing by robots in controller

0

I'm making use of CodeIgniter 2 to set up a website. The admin area is in the url http://meudominio.com/mod , to access you need to go through login.
To avoid indexing the search engines, I configured the routes file

$route['mod/(:any)'] = "$1";
$route['mod_upload'] = '';
$route['mod_config'] = '';
$route['mod_logo_upload'] = '';

Access to the controller is thus http://meudominio.com/mod/mod_upload
http://meudominio.com/mod/mod_config
http://meudominio.com/mod/mod_logo_upload

To avoid indexing the pages, and ending up appearing in google, just "lock the directory / mod" in the roobts.txt file? or just the login will be enough?

    
asked by anonymous 05.06.2015 / 04:09

1 answer

2

If these routes have authentication, probably unauthenticated users are redirected should see the login page, in case a BOT should also view the login page (because in my opinion the bots should see the pages in the same way as the user ), if this is the case you can use the http code 401 (Unauthorized):

  • php 5.4 +:

    if (false === $condicao_necessaria_para_acesso) {
        http_response_code(401);
        //View para login
    } else {
        //Condição normal, views, models, etc
    }
    
  • php below 5.4:

    if (false === $condicao_necessaria_para_acesso) {
        header('X-PHP-Response-Code: 401', true, 401);
        //View para login
    } else {
        //Condição normal, views, models, etc
    }
    

If the page does not have authentication, but the route is accessible by an address or by a specific%%, you can use http code 403 (Forbidden) with user-agent , so you do not need to send a custom page if the browser when it does not have content usually shows a standard error page of it and the search engines do not index this page.

  • Use a condition to enter access:

    if (false === $condicao_necessaria_para_acesso) {
        http_response_code(403);
        exit;
    }
    
  • php < 5.4:

    if (false === $condicao_necessaria_para_acesso) {
        header('X-PHP-Response-Code: 403', true, 403);
        exit;
    }
    
05.06.2015 / 04:23