httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Cardwell <>
Subject Re: [users@httpd] mode_rewrite hostnames and wikiwords
Date Mon, 07 Jan 2008 11:05:56 GMT
Dragon wrote:

>> hit a snag
>> how would I expand this rule to capture and convert the following?
>> -> YourHostName (works with rule)
>> YOUR.HOST.NAME -> YourHostName (currently not handled)
>> -> YourHostName (currently not handled)
>> effectively the spec would be to take /doc/FQDN (regardless of case 
>> presented)
>> and capitaliseing every dot separated word returning
>> /doc/FullyQualifiedDomainName removing any characters other than 
>> [A-Z][a-z][0-9]

RewriteEngine On
RewriteMap    uppercase int:toupper
RewriteMap    lowercase int:tolower
RewriteRule   ^/doc/(.*)$                     /doc2/${lowercase:$1}
RewriteRule   ^/doc2/(.*?)[^.a-zA-Z0-9]+(.*)$ /doc2/$1$2                [N]
RewriteRule   ^/doc2/((.*)\.)?([a-z])(.*)$    /doc2/$2${uppercase:$3}$4 [N]
RewriteRule   ^/doc2/(.*)                     /wiki/$1                  [PT]

> If I were to do something like this, I would most likely use the 
> RewriteMap directive to pass the incoming URL to a short Perl script to 
> do the transformation. The stdin file handle presents the program with 
> the request URL and you pass the result back via the stdout file handle.
> See the section on the page linked above entitled "External Rewriting 
> Program" for details and a skeleton Perl script you can add your 
> processing to.

IMO, you should only use external rewrite programs as a last resort. If 
you can use the inbuilt apache functions you should do so.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message