Invalid command error when adding Redirect in cPanel (SOLVED)

sneader

Well-Known Member
Aug 21, 2003
1,170
53
178
La Crosse, WI
cPanel Access Level
Root Administrator
A customer added a subdomain in cPanel, which they wanted to redirect to another website. When they use the Redirect feature in cPanel to add the redirect, they received an error, as follows:

Subdomain Redirection

foo.example.com is currently being redirected to: unchanged(Apache detected an error in the Rewrite config.
Syntax error on line 1 of /home/example/public_html/.htaccess.SS4E3unJ7jwRQDXYxJE8UyGKYLlOL_aC:
Invalid command 'suPHP_ConfigPath', perhaps misspelled or defined by a module not included in the server configuration
Please try again.) .

The first line of their .htaccess has:

suPHP_ConfigPath /home/example/public_html/

That line is there because the customer has their own custom php.ini, and this line tells Apache to use the php.ini in the public_html directory for all subdirectories, too (otherwise the customer would need to have separate php.ini files for every subdirectory that needs overrides).

SOLUTION:

I opened a ticket with cPanel, to see if this was a bug or if we were doing something wrong. Turns out we were doing it wrong. :) Here's the solution... need to wrap the suPHP_ConfigPath directive in an ifModule....

This is because of the file test that is performed.

[email protected] [~]# /usr/local/apache/bin/httpd -DSSL -t -f /home/example/public_html/.htaccess
Syntax error on line 1 of /home/example/public_html/.htaccess:
Invalid command 'suPHP_ConfigPath', perhaps misspelled or defined by a module not included in the server configuration

The file test only checks for statically compiled modules, and suPHP is a dynamically/shared loaded module, so it fails here. You need to wrap the directive in the proper module load commands.

[email protected] [~]# /usr/local/apache/bin/httpd -DSSL -t -f /home/example/public_html/.htaccess
Syntax OK
[email protected] [~]# cat /home/example/public_html/.htaccess

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/example/public_html/
</IfModule>
I hope this helps someone else in the future.

- Scott