Configuration using rewrite directive with CGI

Configuration using rewrite directive with CGI

The big difference when using CGI/FastCGI instead of mod_php is, that the variables $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW] are not existent. The authentication method is therefore slightly different.

Environment: openSUSE 11.0 with Plesk 9.2.3, Apache 2.2.14 (mpm-worker), PHP 5.2.9, tine20-allinone-2010-03-ms1-1

Create a wrapper-script '/srv/www/cgi/php-cgi-wrapper':

#!/bin/sh
PHPRC="/etc/php5/fastcgi"
export PHPRC
exec /usr/bin/php-cgi5

The owner of the wrapper-script and the directory '/srv/www/cgi' has to be identical to the

SuexecUserGroup <user> <group>

statement.

The domain is configured in Plesk with setting 'FastCGI for PHP' and the corresponding 'httpd.include' should contain:

<IfModule mod_fcgid.c>
  <Files ~ (\.php)>
    SetHandler fcgid-script
    FCGIWrapper /srv/www/cgi/php-cgi-wrapper .php
    Options +ExecCGI
    allow from all
  </Files>
</IfModule>

As next, you have to add rewrite-rules to your vHost configuration:

Tine20 is installed in the document root

<VirtualHost *:80>
  DocumentRoot "/path/to/your/tine20_installation"
  .....
  <Directory "/path/to/your/tine20_installation">
    .....
  </Directory>
  .....
  RewriteEngine on
  RewriteCond %{HTTP:Authorization} ^(.*)
  RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
  RewriteRule /Microsoft-Server-ActiveSync(.*) /index.php$1 [E=ACTIVESYNC:true,E=REMOTE_USER:%{HTTP:Authorization}]
</VirtualHost>


Tine20 is installed in a subdirectory of your document root

<VirtualHost *:80>
  DocumentRoot "/var/www/tine20"
  .....
  <Directory "/var/www/tine20">
    .....
  </Directory>
  .....
  RewriteEngine on
  RewriteCond %{HTTP:Authorization} ^(.*)
  RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
  RewriteRule /Microsoft-Server-ActiveSync(.*) /subfolder/below/documentroot/tine20_installation/index.php$1 [E=ACTIVESYNC:true,E=REMOTE_USER:%{HTTP:Authorization}]
</VirtualHost>

If you don't have access to your Apache configuration (e.g. in a shared hosting environment) you can alternatively add the code above to the '.htaccess' file in your webservers root directory (see previous section).