Monotoba Posted November 13, 2007 Share Posted November 13, 2007 Can anyone here help me with a small problem I'm having? I am trying to use PHP4/5 to implement a mod_rewrite script using apache2 mod_rewrite's "prg" map type. The reason for this is that I need to dynamically redirect urls using a database of mapping values. A seperate script will be used to edit the db records. My development environment is WAMP on Vista. I am calling my php script from a bat file. The issue I am having is that I can't seem to get php to read or write on the stdin and stdout. My test php code to accomplish this is as follows: <?php /** * Test script to echo url back to mod_rewrite */ $stdin = fopen('php://stdin', 'r'); $request = fread($stdin, 1024); $stdout = fopen('php://stdout', 'w'); $map_path = $request; fwrite($stdout, $map_path, 1024); ?> My MySQL Table looks like this: CREATE TABLE `routes` ( `id` int(11) NOT NULL auto_increment, `request_url` varchar(255) NOT NULL, `local_path` varchar(255) NOT NULL, `ordinal` tinyint( NOT NULL, `status` varchar(20) NOT NULL, PRIMARY KEY (`id`), KEY `request_url` (`request_url`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT=\'This table holds server site url mappings\' AUTO_INCREMENT=0 ; And my Apache Config lcontains this: # # Mod Rewrite # <IfModule rewrite_module> # # Use # RewriteEngine on RewriteMap db_route_map prg:"C:/wamp/apache2/db_route/db_route.bat" RewriteRule ^/(.*)$ /${db_route_map:$1} </IfModule> The completed script will return the mapped paths contained in the db. I suspect that I am not access the the stdin and stdout correctly. Any ideas? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.