1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Code Question

Discussion in 'PHP' started by jasontn, Mar 27, 2015.

  1. #1
    This supposed to be a "robots exclusion code" for a traffic stat widget plugin (WordPress).

    RewriteRule robots\.txt robots.php
    
    RewriteRule robots.txt robots.php
    Code (markup):
    Are these two lines of code the same? Which should be put on a .htaccess file?

    It works with this line of code robots.php that is put on the root directory

    <?php
    session_start();
    $_SESSION['wtcrobot'] = 1;
    echo file_get_contents('robots.txt');
    exit;
    ?>
    Code (markup):
     
    jasontn, Mar 27, 2015 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    the one with the \. is correct writen, that one should be used.
     
    EricBruggema, Mar 27, 2015 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #3
    Why would you even do that other than making code bloat... since the overhead of running PHP and the extra request handling on a static file not only takes more time, but would also not work since most bots don't preserve cookies and as such cannot maintain a session!?! (since sessions use ONE cookie to work)

    Doesnae make much sense; in fact looks totally banjaxed. Exit for nothing, echoing a file_get_contents instead of using readFile, session that shouldn't work given the target file...
     
    deathshadow, Mar 28, 2015 IP