php to html using htaccess

Discussion in 'Programming' started by Christian, Jan 18, 2011.

  1. #1
    Hello

    I'm using htaccess to convert my php files to html
    e.g. index.php to index.html , ...
    but I want to make php files unavailabe for users.
    I want users only access to html files and when they try to access a php file they get an error.
    also I want to prevent robots like googlebot from accessing my php files.
    How can I do this?
    Is it possible to make php files unreachable forever?

    Kind Regards,
    Rezaa
     
    Christian, Jan 18, 2011 IP
  2. BreezeTR

    BreezeTR Well-Known Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #2
    To the top:
    <? ob_start(); ?>

    <?
    $text=$_SERVER['SCRIPT_FILENAME'] ; // http://www.blabla.com/.../sth.php
    echo $text;
    $filename = basename($text, ".php"); // sth
    $filename= $filename.".html"; // sth.html

    if (strpos( $_SERVER['HTTP_USER_AGENT'], 'Googlebot' ) == false ) header("location: $filename");
    ?>
     
    BreezeTR, Jan 18, 2011 IP