Jump to content

Apache Php Rewrite


Monotoba

Recommended Posts

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(8) 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?

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/77139-apache-php-rewrite/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.