This is a discussion on How to mod_rewrite user directories with a CGI? within the Linux Web Servers forums, part of the Web Server and Related Forums category; Hello: I am trying to create custom user directories using mod_rewrite with a CGI script. I am running Apache/1....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello:
I am trying to create custom user directories using mod_rewrite with a CGI script. I am running Apache/1.3.33 (Unix). I've added the following rules to my httpd.conf file under the respective virtual host that they apply to. <IfModule mod_rewrite.c> RewriteEngine On RewriteOptions inherit RewriteCond %{HTTP_HOST} ^www\.mysite\.com [OR] RewriteCond %{HTTP_HOST} ^mysite\.com RewriteRule ^/~([a-zA-Z0-9_]+)$ /services/homepage.cgi?$1 [L] </IfModule> The only problem is, even with UserDir explicitly disabled, Apache somehow notices I am trying to usurp control over user directories with a CGI, so apparently at some stage after the rewrite it looks back at the original request-URL again and secretly issues a getpwnam command (evidenced by the error_log output), thus denying the CGI script from running because it can never find the appropriate username in the password file. This only happens if I try to do rewriting on URLs with a tilde and a CGI script as the target. Keep in mind, I do have ExecCGI enabled for the entire site under this virtual host. And, this all works just fine if I rewrite to a .html file, for example. I suppose my last resort is to simply move the rewrite into the ..htaccess file under my site's htdocs. But that is really more of a kludge than a solution. What should I do? TIA, --Randall |
|
|||
|
I found the solution. Apparently by doing a PT (pass through) it
bypasses the internal user directory hook entirely. According to the docs, PT is specifically designed to aid in cross-compatibility with other URL-to-file translation mechanisms. It's likely the tilde's special meaning to the operating system (not necessarily Apache itself) is causing some point of internal confusion, so a pass-through is necessary. --Randall |