Forum Moderators: phranque

Message Too Old, No Replies

file_get_contents

html replace

         

smallcompany

2:46 am on Jun 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi,

I use a small PHP script in order to track keywords while people browse through my websites. I use it combined with .htaccess where I have this:

RewriteEngine On
#RewriteBase /
rewriterule ^(.*)\.htm$ [mysite...]

The PHP script is this:

<?

$f=file_get_contents("filename.htm");
echo str_replace("{kw}",$_SERVER["QUERY_STRING"],$f);

?>

The problem is that in a place of “filename.htm” within the script I have to put the corresponding name of HTM file and save it as filename.php

This means that if I have 88 HTM files that are making my website, I have to create 88 PHP files and put the corresponding name into each script.

Is there a way of replacing “filename.htm” with something so it automatically picks a name from HTM file? That way two files per folder would be needed (.htaccess and one PHP file). That would be a relief!

Thanks

coopster

5:03 pm on Jun 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, smallcompany.

Have a look at some of your other $_SERVER variables, notably

REQUEST_URI
. We have a superglobals script in the WebmasterWorld PHP Forum Library [webmasterworld.com] thread titled Good PHP solutions to small problems [webmasterworld.com] (message number 2) that may be of interest.