Forum Moderators: phranque
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
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.