apache/mod_rewrite: global external RewriteMap

This is a discussion on apache/mod_rewrite: global external RewriteMap within the Apache Web Server forums, part of the Web Server and Related Forums category; hi ng, i have the following problem: i am using an external RewriteMap RewriteCond %{REQUEST_URI} .html$ RewriteMap rewrite-static prg:/...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-16-2004
Manuel Machajdik
 
Posts: n/a
Default apache/mod_rewrite: global external RewriteMap

hi ng,

i have the following problem:

i am using an external RewriteMap

RewriteCond %{REQUEST_URI} .html$
RewriteMap rewrite-static prg:/usr/local/bin/rewrite_static
RewriteRule ^/(.*).html$ /${rewrite-static:$1}

to transform static urls into dynamic ones for php.

I am using vhosts (about 500) and would like to use this rewriting in every
vhost.
When I put the above lines in all of my vhost files, apache opens the file
/usr/local/bin/rewrite_static once for every vhost and runs out of memory.
When I put the above lines to my httpd.conf, the rule does not work at all.
Why? do I have to put it in a special section (tried IfModule)?

Or is there any other way to transform a url like

/index,lang,en,id,8.html

into

/index.php?lang=en&id=8

for an unknown number of key/value pairs? (in normal RewriteRules only 4
key/value pairs are allowed, as the max. number of backreferences is $9)

any help or ideas appreciated!!

manu


  #2 (permalink)  
Old 01-17-2004
Joachim Ring
 
Posts: n/a
Default Re: apache/mod_rewrite: global external RewriteMap

> i am using an external RewriteMap
>
> RewriteCond %{REQUEST_URI} .html$
> RewriteMap rewrite-static prg:/usr/local/bin/rewrite_static
> RewriteRule ^/(.*).html$ /${rewrite-static:$1}
>
> to transform static urls into dynamic ones for php.
>
> I am using vhosts (about 500) and would like to use this rewriting in every
> vhost.
> When I put the above lines in all of my vhost files, apache opens the file
> /usr/local/bin/rewrite_static once for every vhost and runs out of memory.
> When I put the above lines to my httpd.conf, the rule does not work at all.
> Why? do I have to put it in a special section (tried IfModule)?


do you have a RewriteEngine On in the httpd.conf? it should certainly
be possible to have rewrite rules in the main server config.

> Or is there any other way to transform a url like
>
> /index,lang,en,id,8.html
>
> into
>
> /index.php?lang=en&id=8
>
> for an unknown number of key/value pairs? (in normal RewriteRules only 4
> key/value pairs are allowed, as the max. number of backreferences is $9)


if the max number of name/value pairs is known:

RewriteEngine On
RewriteRule /([^,\.]+),([^,\.]+),([^,\.]+)(.*) /$1$3?$1=$2 [C,QSA]
RewriteRule /([^,\.]+),([^,\.]+),([^,\.]+)(.*) /$1$3?$1=$2 [C,QSA]
....
RewriteRule /([^,\.]+),([^,\.]+),([^,\.]+)(.*) /$1$3?$1=$2 [C,QSA]
RewriteRule /([^,\.]+),([^,\.]+),([^,\.]+)(.*) /$1$3?$1=$2 [QSA]

RewriteRule (.*)\.html $1.php

each of the above rules takes the first name/value pair and attaches
it to the query string. since it is chained, the next rule pair will
be tried. when all name/value pairs are gobbled up, only index.html
will be left in your example and the regex of the next rule will not
match, therefore breaking out of the sequence. just make shure you've
got enough lines for all your name/value pairs.
brave people may try just one line with [N] or [R] flags to make a
loop instead for a finite but not formerly known number of name/value
pairs, but one easily has an infinite loop which tends to annoy
clients...

joachim
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0