Using index.php to hide your programming language

You see, if you’d used mod_rewrite you could have issued 302 Moved Permanently headers to the spiders and given them the new URL without losing page rank.

Again, throw that book away - author is an idiot.

Michael,
Thanks for the advice.
What I did to fix the situation I’m in is changed all of the .html product files to php and used


<?php

    // sample new url: mysite.com/productinfo/12345/title-of-page.php
    // sample old url: mysite.com/productinfo/12345/title-of-page.html

    $sku = "item_number";
    $title4 = "title with spaces removed and - inserted";

    $extension = strrchr($phpself, '.');
    
    $forwardpage = '' .$domain. '/productinfo/' .$sku. '/' .$title4. '';
    $exten = ".php";
    $forwardpage = '' .$forwardpage. '' .$exten. '';
    
    if ($extension==".html") {
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://$forwardpage" );
    // echo $forwardpage;
    exit();
    }


    $forwardpage2 = '/productinfo/' .$sku. '/' .$title4. '';
    $exten = ".php";
    $forwardpage2 = '' .$forwardpage2. '' .$exten. '';
    $forwardpage3 = '' .$domain. '' .$forwardpage2. '';

    if ($phpself != $forwardpage2) {
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://$forwardpage3" );
    // echo $forwardpage2;
    exit();
    }

?>

So now, when you click the old links with .html as the extension you are redirected to the new actual page. If you remove the /title4.php section it will redirect 301 perm to the correct item number and title page.

I did this not to cover my tracks and cloak any pages, but it’s for seo reasons and to make the urls more presentable. I did contact them with a reconsideration request and hope they respond. LOL

:fingerscrossed: :smiley:

also in the above code, if you mess with the item number by inserting code to check if a dynamic page comes up…it errors 404. If you add or subtract letters or numbers to the title4.php section, it redirects 301 perm. to the actual title4.php.
If you click on the old .html links it redirects 301 perm to the new actual url.

I don’t think this is considered cloaking the url. I would feel better if they would actually call me so I can explain why I do what I do. LOL

Thanks,
Kevin

Ok,
Just tweaked the code to this:


<?php

    $extension = strrchr($phpself, '.');
    
    $forwardpage = '/productinfo/' .$sku. '/' .$title4. '';
    $exten = ".php";
    $forwardpage = '' .$forwardpage. '' .$exten. '';
    $forwardpage2 = '' .$domain. '' .$forwardpage. '';

    if ($phpself != $forwardpage) {
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://$forwardpage2" );
    // echo $forwardpage2;
    exit();
    } else {
    Header( "HTTP/1.1 200 OK" );
    }

?>

If the ‘if’ statement errors then it will 301 to the actual url.
if the ‘if’ statement doesn’t error, it outputs a 200 ok. It seems to work.

Thanks,
Kevin