combining .htaccess

combining .htaccess

Posted by: Diggory
Posted on: 2008-11-25 08:10:00

Hello,

I've got a site on DH and am having an issue with .htaccess files.

I've developed this site using a PHP framework called CodeIgniter which uses mod_rewrite as so:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|public|user_guide|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

Which works fine.

However I also want to use a PHP wrapper to use my own custom php.ini like so:

<IfModule mod_actions.c>
Action php-cgi /cgi-bin/php-wrapper.cgi
Action php5-cgi /cgi-bin/php-wrapper.cgi
</IfModule>

If I try either of these as the .htaccess they work - however I would like both of them, so I combined them into one .htaccess file like so:

<IfModule mod_actions.c>
Action php-cgi /cgi-bin/php-wrapper.cgi
Action php5-cgi /cgi-bin/php-wrapper.cgi
</IfModule>

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|public|user_guide|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

But I always get a 500 error from the server when the .htaccess file is like that.

Does anyone know what I'm doing wrong? Why do they work individually, but not combined?

Re: combining .htaccess

Posted by: sXi
Posted on: 2008-11-25 08:17:00

Have you tried it adding a handler in mod_actions.c?

AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi




How To Install PHP.INI / ionCube on DreamHost

Re: combining .htaccess

Posted by: Diggory
Posted on: 2008-11-25 08:23:00

Hmm - just tried adding the handler as you suggested, it didn't appear to make a difference.

I've also just worked out where DH stores my logs and found the error log:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Is the combination of the two sets of directives causing an infinite loop?

Success!

Posted by: Diggory
Posted on: 2008-11-25 08:28:00

I've managed to solve it like this:

<IfModule mod_actions.c>
Action php-cgi /cgi-bin/php-wrapper.cgi
Action php5-cgi /cgi-bin/php-wrapper.cgi
</IfModule>

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

RewriteCond $1 !^(index\.php|public|stats|user_guide|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>

Tags: htaccess filesdh