Custom PHP.ini redirect problem

software development

#1

This is the background:
I have a custom CGI script that runs php from a location outside my document root (makes it easy and clean to update both PHP and PHP.ini).

My .htaccess for the / looks like this:
Options -Indexes +ExecCGI
RewriteEngine On
RewriteBase /

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

RewriteCond %{HTTP_HOST} !^www…*
RewriteRule ^.*$ http://www.crazytuesday.com%{REQUEST_URI} [R=301,L]
-eof-

What it’ll do is redirect all non-www to www. Simple.
This is the scenarios.

http://www.crazytuesday.com/dir - works
http://crazytuesday.com/dir - works (redirects to www)
http://www.crazytuesday.com/dir2 - works
http://crazytuesday.com/dir2 - does NOT work.

There’s ONE difference between dir and dir2. dir2 contains a .htaccess with RewriteEngine On and RewriteBase /dir2.

What happens is that PHP pukes out a error message
"This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive."

Is it impossible to have nested RewriteRules when running a custom php cgi or am I missing something?


#2

I’m not fully following your problem, as I never really needed to change PHP much, but… if your problems are coming from redirecting to www., why not just set your domain to www-only in the control panel & leave that part out of the .htaccess file?


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#3

I’ve tried that, that caused additional problems.

crazytuesday.com/path redirected to www.crazytuesday.compath.

It’s not a very big problem, except if you’re trying to have independent sites in a sub-directory.


#4

You might want to run that one by support. I can’t imagine how forcing www through the panel could lead to stripping the / out of the request_uri.

There must be a screwy setting somewhere.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.