Tjoekbezoer van Damme wrote:
I've got PHP set up to the point where it will process files ending in
.php, but I want to "blanket" the processing of PHP code under IIS in
the same manner in which I blanket PHP code with Apache.
If anyone has any suggestions, other than reading PHP's manual which
I've read several times which does not cover this, I would greatly
appreciate it.
I wrote a little 'hack' to mimic modrewrite for IIS. When you get a
404 error page in IIS, you get the URL of the originally requested
page in the $_SERVER['QUERY_STRING'] variable. So by creating a custom
404 error page with this knowledge you can mimic the basic
functionality of modrewrite:
<?php
/*
Simple PHP script that imitates mod_rewrite for IIS 6.0
Set this script to be your 404 error document in the folder where you
want mod_rewrite to be enabled
Your rule can contain regular expressions in the Perl 5 syntax (PCRE).
You can use references in your target ($1, $2, etc) to refer back to
parts of your rule.
*/
$rule = "/(.*?)\/content\/([a-zA-Z0-9]+)\/([0-9]+)/m"; // Original URL
that is typed in the browser
$target = "/oilpowered.com/index.php?type=$2&id=$3"; // Redirect to
the new URL. Only relative URLs!
$qs = $_SERVER['QUERY_STRING'];
$url = substr( $qs, strpos( $qs, ";" )+1 );
// TODO: $page - preg_replace() in the if clause, to save one regexp?
if( preg_match( $rule, $url ) > 0 )
{
$page = preg_replace( $rule, $target, $url );
header( "Referer: " . $_SERVER['HTTP_REFERER'] );
header( "Location: " . $page );
}
?>
Hope this helps,
Tjoek
Hello, and thanks for the reply, Tjoek -
However, this really isn't what I'm looking for. I'm simply looking for
a way to parse PHP code from within existing HTML pages, so that I can
migrate a site from Apache to IIS6.0.
Like I said, if I were using Apache, I would just add .html to my
AddType directive, and call it good. Is it not this simple under IIS?
Thanks
-dant
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php