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:/...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
> 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 |