Mod-rewrite detection doesn't work when PHP is installed as CGI on 5.2.0

58 views
Skip to first unread message

Alexander Obuhovich

unread,
Sep 28, 2012, 6:25:20 AM9/28/12
to Bugs In-Portal
When PHP is installed as CGI and not as "mod_php" into apache, then system requirements step tells, that mod rewrite is not available.
But in fact mod rewrite works absolutely normally.

I propose to improve detection as advised by http://christian.roy.name/blog/detecting-modrewrite-using-php article by setting custom environment variable in .htaccess file, like this:

<IfModule mod_rewrite.c>
// Tell PHP that the mod_rewrite module is ENABLED.
SetEnv HTTP_MOD_REWRITE On
</IfModule>

and checking it later inside PHP:

if ( function_exists('apache_get_modules') ) {
$modules = apache_get_modules();
$mod_rewrite = in_array('mod_rewrite', $modules);
} else {
$mod_rewrite =  getenv('HTTP_MOD_REWRITE')=='On' ? true : false;
}


I also recommend wrapping whole rewrite-related code inside that IfModule statement since if mod-rewrite is really unavailable, then any directive from it (e.g. RewriteEngine) could cause "500 Internal Server Error" for whole website.


--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com

Dmitry A.

unread,
Oct 24, 2012, 2:20:57 AM10/24/12
to in-port...@googlegroups.com
Agreed - let's create a new task for this and fix it.

DA

Alexander Obuhovich

unread,
Nov 5, 2012, 11:29:11 AM11/5/12
to Bugs In-Portal
Task: http://tracker.in-portal.org/view.php?id=1427


--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To view this discussion on the web visit https://groups.google.com/d/msg/in-portal-bugs/-/_5rxsiEjecYJ.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.

Dmitry Andrejev

unread,
Nov 19, 2012, 5:16:45 PM11/19/12
to in-port...@googlegroups.com
Guys,


FYI: proposed solution won't work unless there mod_env installed (and mod_rewrite) in Apache. I just came across the server which doesn't have mod_env which results in 500 error on installation.

It can take some time to determine why there is 500.

What if we make it look something like this:

=========
<IfModule mod_rewrite.c>

<IfModule mod_env.c>
## Tell PHP that the mod_rewrite module is ENABLED.
SetEnv HTTP_MOD_REWRITE On
</IfModule>
## Enable mod-rewrite
RewriteEngine On

        .......

</IfModule>
=========


I understand that we won't notice the error in this case and now somehow we need to notify user that mod_env is not installed so Mod-Rewrite might not work correctly in Cron.

What do you think?


DA

Alexander Obuhovich

unread,
Nov 20, 2012, 4:07:07 AM11/20/12
to Bugs In-Portal
Based on Apache documentation (see http://httpd.apache.org/docs/2.0/mod/mod_env.html) module "mod_env" is compiled-in by default for all Apache installations.

That was probably some custom server setup to remove this module. Same for Apache 1.3, which isn't longer maintained.


To view this discussion on the web visit https://groups.google.com/d/msg/in-portal-bugs/-/WGv8pQoM7ZQJ.

To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.
Reply all
Reply to author
Forward
0 new messages